Fundamental

http://msdn.microsoft.com/en-us/library/aa288453%28v=vs.71%29.aspx

What is type safe?

Type safety means that the compiler will validate types while compiling, and throw an error if you try to assign the wrong type to a variable.
Some simple examples:
// Fails, Trying to put an integer in a string
String one = 1;
// Also fails.
int foo = "bar";
This also applies to method arguments, since you are passing explicit types to them:
int AddTwoNumbers(int a, int b)
{
    return a + b;
}
If I tried to call that using:
int Sum = AddTwoNumbers(5, "5");

Pradeepta: Upload Resource By FileUpload control

Pradeepta: Upload Resource By FileUpload control

Javascript in saparate js file

 if(!Page.IsPostBack)
{
if(!Page.IsClientScriptBlockRegistered("MyScript") )
{
Page.RegisterClientScriptBlock("MyScript","<SCRIPT Language='JavaScript' src='MyJavaScriptFile.js'></SCRIPT>");
}
Button1.Attributes.Add("onclick","PopWindow();");
}


Let's take a lot at a simple .js file:

function PopWindow()
{

alert('hello world from the Javascript file');

}

ModelPopUp Controls

<asp:LinkButton ID="LinkButton1" runat="server" Text="Click here to change the paragraph style" />
        <asp:Panel ID="Panel1" runat="server" Style="display: none">
            <asp:Panel ID="Panel3" runat="server" CssClass="modalPopup">
                <asp:Panel ID="TitleBar" runat="server" CssClass="modalPopupTitleBar">
                    <asp:Literal ID="Literal1" runat="server" Text="Title here"></asp:Literal>
                </asp:Panel>
                <div>
                    <p>Choose the paragraph style you would like:</p>
   <!-- etc... sample page contents omitted for brevity --->
                </div>
            </asp:Panel>
        </asp:Panel>
        <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="LinkButton1"
            PopupControlID="Panel1" BackgroundCssClass="modalBackground" OkControlID="OkButton"
            OnOkScript="onOk()" CancelControlID="CancelButton" DropShadow="True" Drag="True"
            PopupDragHandleControlID="TitleBar" />







.modalPopupTitleBar {
    background-color:Blue;
    border-width:0px;
    border-style:outset;
    border-color:Blue;
    padding:3px;
    height:15px;
    color:White;
    font-weight:bold;
    border-bottom:outset 2px;
}

External js file include in .aspx file.

 <script type="text/javascript" src="../scripts/popup.js"></script>



inside popup.js
-----------------
function map(func) {
    var i,j,o;
    var results = [];
    if (typeof(func)=="string") {
        func = new Function('$_',func);
    }
    for (i=1; i<arguments.length; i++) {
        o = arguments[i];
        if (isArray(o)) {
            for (j=0; j<o.length; j++) {
                results[results.length] = func(o[j]);
            }
        }
        else if (isObject(o)) {
            for (j in o) {
                results[results.length] = func(o[j]);
            }
        }
        else {
            results[results.length] = func(o);
        }
    }
    return results;
};

How to add dll in to our application

Right click on the application and add reference then select the .dll and ok.


 That dll will be added in the bin folder.

App_Code folder in asp .net

We Can add class files inside the folder.When we add a class file inside this folder that file will be accessed through out the application.We can also add Folder inside it and class file inside that folder.

Create virtual directory

Go to run ->type inetmgr->From left side panel enlarge till getting the Default web sites->Right click on Default web sites ->Add virtual directory->A new window will open->Give alias name (Name by which you access your application)->Give physical path of your application folder by browsing->Select OK->Right click on the web side you have created now from the left side with your alias name ->convert to application->Ok->Then select the directory from the left panel and double click on Default document ->It will open a new window ->Right click on that and select add->it will open a new window here give the page name  of your application which will be displayed as the start page->ok-> select the page name which you have given now in the middle tab-> Take this to the top .

How to assign a Master page to a newly created web page

Right click on any folder where you want to add a new page ->Add new item->Select web form and give the name->CHECK THE CHECK BOX SELECT MASTER PAGE->Add->here it will show all master pages to choose->Select any one and click on OK.

Differences

Abstract Class vs Interface

Theoretically there are basically 5 differences between Abstract Class and Interface which are listed as below :-
  1. A class can implement any number of interfaces but a subclass can at most use only one abstract class.
  2. An abstract class can have non-abstract Methods(concrete methods) while in case of Interface all the methods has to be abstract.
  3. An abstract class can declare or use any variables while an interface is not allowed to do so.
    So following Code will not compile :-
    interface TestInterface
    {
        int x = 4;  // Filed Declaration in Interface
        void getMethod();
        string getName();
    }
    abstract class TestAbstractClass
    {
        int i = 4;
        int k = 3;
        public abstract void getClassName();
    }
    It will generate a compile time error as :-
    Error    1    Interfaces cannot contain fields .
    So we need to omit Field Declaration in order to compile the code properly.
    interface TestInterface
    {
        void getMethod();
        string getName();
    }
    abstract class TestAbstractClass
    {
        int i = 4;
        int k = 3;
        public abstract void getClassName();
    }
    Above code compiles properly as no field declaration is there in Interface.
    4. An abstract class can have constructor declaration while an interface can not do so.
    So following code will not compile :-
    interface TestInterface
    {
        // Constructor Declaration
        public TestInterface()
        {}
        void getMethod();
        string getName();
    }
    abstract class TestAbstractClass
    {
        public TestAbstractClass()
        {}
        int i = 4;
        int k = 3;
        public abstract void getClassName();
    }
    Above code will generate a compile time error as :-
    Error    1    Interfaces cannot contain constructors
    So we need to omit constructor declaration from interface in order to compile  our code .
    Following code compile s perfectly :-
    interface TestInterface
    {
        void getMethod();
        string getName();
    }
    abstract class TestAbstractClass
    {
        public TestAbstractClass()
        {}
        int i = 4;
        int k = 3;
        public abstract void getClassName();
    }
    5.   An abstract Class is allowed to have all access modifiers for all of its member declaration while in interface  we can not declare any access modifier(including public) as all the members of interface are implicitly public.
    Note here I am talking about the access specifiers of the member of interface and not about the interface.
    Following code will explain it better :-
    It is perfectly legal to give provide access specifier as  Public (Remember only public is allowed)
    public interface TestInterface
    {
        void getMethod();
        string getName();
    }
    Above code compiles perfectly.
    It is not allowed to give any access specifier to the members of the Interface.
    interface TestInterface
    {
        public void getMethod();
        public string getName();
    }
    Above code will generate a compile time error as :-
    Error    1    The modifier 'public' is not valid for this item.
    But the best way of declaring Interface will be to avoid access specifier on interface as well as members of interface.
    interface Test
    {
        void getMethod();
        string getName();
    }
    string.Empty() and ""
    The difference between string.Empty and “” is very small. String.empty will not create any object while “” will create a new object in the memory for the checking. Hence string.empty is better in memory management.

    String.Empty is a readonly field, while "" is a constant
    Consider this code snippet.
    private void button1_Click(object sender, EventArgs e)
            {
               string s = textBox1.Text;
                switch (s)
                {
                    case String.Empty:
                        MessageBox.Show("blank");
                        break;
                }
            }
    //Compiler will generate an error
    //A constant value is expected
    //So, if we use "" in place of String.Empty, no error will be generated.

     
    For And ForEach
    1. The for loop executes a statement or a block of statements repeatedly until a specified expression evaluates to false. The for loop is useful for iterating over arrays and for sequential processing.
    2. Because the test of a conditional expression occurs before the execution of the loop, a for statement executes zero or more times.
    3. The foreach statement repeats a group of embedded statements for each element in an array or an object collection. The foreach statement is used to iterate through the collection to get the desired information, but should not be used to change the contents of the collection to avoid unpredictable side effects.
    4. foreach loop may (not always, but depends) reduce the performance of the code. Therefore for loop is recommended.

    Array And ArrayList
    There are several differences, but the biggest, in my opinion, is that an arraylist grows as you add items to it and does not have to be redimmed the allow additional elements. Arraylists are sortable, searchable, etc - they are far superior to arrays.
    When you have a fixed array, there is in use no difference.Arrays cannot be changed in size at runtime (except using 'ReDim' which will create a new array, copy the old array in the new array and destroy the old array). The arraylist is more dynamic, you can add and remove items without loosing performance.
    1.An array can be of any data type and contain one data type while array list can contain any data type in the form of the object.
    2) With array you can not dynamically increase or decrease the size of array dynamically. You must define the size of the array. You can change the size of the array with redim statement but still you have to define type. While with array list you can make list of any sizes. When a element or object is added to array list it size is automatically increase the capacity of the array list.
    3) Once you delete the item in array it kept that one as empty like a[2]="" but in case of arraylist a[3]index occupies the position of a[2] and also if you try to insert a[2] value array will throw error if any items reside inside but in case of arraylist a[2] is inserted in same position but at the same time position of a[2] become a[3] if there is already an item exists.
    ArrayList is an extended managment of Arrays....
    ArrayList can hold objects(custom...or...defined) say i have an object user with properties name and email my AraayList can hold users object...means one or more
    Array is Type specific....so can hold Types like int, string etc......
    ArrayList class implements IList interface using an array.
    Advantages:
    ARRAYLIST
    Its capacity is increased if required as objects are added to it. So it frees programmer from the worries of array overflow.
    Provides methods to perform common operations -- append, insert,remove, replace etc. 
    There is no restriction on the type of objects which can be added to an arraylist.
    First object could be a string, second a double, third a user defined object and so on.
    ArrayList can be made read only after adding elements to prevent unintentional modifications.
    It provides an overloaded method to perform binary search on its objects.
    ArrayList is also a datastructure in dotnet which contain data in it .

    The major difference in between array and arraylist is insertion and deletion of data .
    In ArrayList we can eaisely insert Data at a particular location while in array it is not possible.


    Array is for homogeneous data. i.e data of same data type. Whereas Array list is for Heterogeneous data.

    The data in the arraylist need not be of same data type. Also it(arraylist) can store objects. say objects of type account. Suppose that u r using an array of intgers.Which may contain any numer of integers which you know only at runtime.
    So while coding u cannot specify the size of the Array.
    Array list is used to solve this problem.
    It has a default size that is 16 items. if u have even 1 item the size will be 16. After 16 if u add another item, the size increases to 32. i.e the array List size can be increased dynamically.
    Difference between array.clone() and array.copyto()

    Clone() just implements the ICloneable interface. It creates new instance of array holding the same elements, but returns object you have to cast.

    ArrayCopy() is static helper method. It copies elements from one array to another. The destination array has to be already created with right dimension. You can use this method instead for loop.
    object[] objects1 = { "one", "two", "three" };
               object[] objects2 = { 0, 1, 2, 3, 4, 5 };
               Console.Write("objects1 array elements: ");
               foreach (object o in objects1)
               {
                   Console.Write("{0} ", o);
               }
               Console.Write("\nobjects2 array elements: ");
               foreach (object o in objects2)
               {
                   Console.Write("{0} ", o);
               }
               objects1.CopyTo(objects2, 1);//inside object2 object1 will be..
               Console.Write("\nobjects2 array elements: ");
               foreach (object o in objects2)
               {
                   Console.Write("{0} ", o);
               }
    //OutPut 0 one two thee 4  5
               object[] objects3 = (object[])objects1.Clone();
               Console.Write("\nClone of objects1 array elements: ");
               foreach (object o in objects3)
               {
                   Console.Write("{0} ", o);
               }
    //Out put one two thee
               Console.WriteLine();
               Console.ReadLine();
    Difference between stored procedure and functions in SQL Server
    1. Functions are compiled and executed at run time.
    Stored procedures are stored in parsed and compiled format in the database.
    2. Functions cannot affect the state of the database which means we cannot perform insert,delete,update and create operations on the database.
    Stored Procedures can affect the state of the database by using insert,delete,update and create operations.
    3 Functions are basically used to compute values. We passes some parameters to functions as input and then it performs some operations on the parameter and return output.
    Stored procedures are basically used to process the task.
    4.Function can not change server environment and our operating system environment.
    Stored procedures can change server environment and our operating system environment.
    5.Functions can not be invoked from SQL Statements. Execute. SELECT
    operating system can be invoked from SQL Statements. Execute. SELECT
    6.Functions can run an executable file from SQL SELECT or an action query.
    operating system use Execute or Exec to run
    Functions
    a) Can return only one value
    b) Called from SQL Query
    c) Compiled and executed during run time
    Stored procedures
    a) Can return more than one value
    b) Can be called from SQL Query
    c) Parsed and Compiled during design time itself
    difference b/w dataset.clone and dataset.copy

    Hi, dataset.clone method copies the structure of the DataSet, including all datatable schemas, relations, and constraints. But it does not copy any data.
    The Clone method of the DataSet class copies only the schema of a DataSet object. It returns a new DataSet object that has the same schema as the existing DataSet object, including all DataTable schemas, relations, and constraints. It does not copy any data from the existing DataSet object into the new DataSet.
    The Copy method of the DataSet class copies both the structure and data of a DataSet object. It returns a new DataSet object having the same structure (including all DataTable schemas, relations, and constraints) and data as the existing DataSet object. Whereas, dataset.copy method copies both the structure and data
    Difference Between Dataset and DataReader
    Nature of Connection:
    Dataset: is generally used to employ disconnected architecture of Ado.Net
    DataReader: is directly connected to database system.
    Local Storage:
    Dataset: It reads data from database and stores in local system.
    DataReader: No Local storage is required.
    Where to use:
    Dataset: If you are going more number of operations(updates, inserts and deletes) on database and updates done in batch wise, then dataset will be best option. Use Dataset, if you are going to implement sites, which are no need of changes on every client clicks, such as "Carting in shoping mall sites", "display information in websites from database".
    DataReader: If you are going to fewer operations and directly implementation of queires on database, the datareader is best option. Use DataReader, if you are going to implement "Booking a berth in Railways", "display current price in Stock Market".
    Performance: Choose Dataset or DataReader According to situation, purpose and uses of database display.
    DataReader
    1. Its an connection oriented, whenever you want fetch the data from database that you need the connection. after fetch the data connection is diconnected.
    2. Its an Read only format, you cann't update records.
    DataSet
    1. Its connectionless. whenever you want fetch data from database. its connects indirectly to the database and create a virtual database in local system. then disconnected from database.
    2. Its easily read and write data from virtual database.
    Nature of Connection:
    Dataset: is generally used to employ disconnected architecture of Ado.Net
    DataReader: is directly connected to database system.
    Local Storage:
    Dataset: It reads data from database and stores in local system.
    DataReader: No Local storage is required.
    Where to use:
    Dataset: If you are going more number of operations(updates, inserts and deletes) on database and updates done in batch wise, then dataset will be best option. Use Dataset, if you are going to implement sites, which are no need of changes on every client clicks, such as "Carting in shoping mall sites", "display information in websites from database".
    DataReader: If you are going to fewer operations and directly implementation of queires on database, the datareader is best option. Use DataReader, if you are going to implement "Booking a berth in Railways", "display current price in Stock Market".
    Performance: Choose Dataset or DataReader According to situation, purpose and uses of database display.
    what is the difference between a candidate key and a primary key?
    Any attribute that is uniquely identify a row in a table is candidate key for the table. We select one of the candidate key as Primary key. All candidate keys which are not chosen as primary key are Alternate keys. The key which uniquely identify the rows of the table and which is made up of more than one attribute is called Composite key. Generally a candidate key becomes the primary key of the table. If the table has more than one candidate key one of them will become the primary key and the rest are called alternate keys.
    Candidate key is a Unique Key and it can be used to find out any purticular Tuple(row) in a table..
    a Primary key is also a Candidate Key...
    But these are the diff..
    1)on a table we can have only 1 primary key but 'N' number of unique keys.
    2)Unique key can be null but not a Primary key
    what is the difference between whereclause and having clause
    The difference between 'where' clause and 'having' clause is
    1.U can use group function/aggregate functions in having clause but u cannot use group function/aggregate functions in where clause. The fundamental difference between WHERE and HAVING is this:  WHERE selects groups of rows before groups and aggregates are computed (thus it controls which rows go into the aggregate computation)
    whereas HAVING selects group rows after groups and aggregates are computed. Thus the WHERE clause must not contain aggregate functions; it makes no sense to try to use an aggregate to determine which rows will be inputs to the aggregates.
    On the other hand the HAVING clause always contains aggregate functions. (Strictly speaking you are allowed to write a HAVING clause that doesn't use aggregates but it's seldom useful. The same condition could be used more efficiently at the WHERE stage.)
    Useful aggregate functions:
    • AVG() - Returns the average value
    • COUNT() - Returns the number of rows
    • FIRST() - Returns the first value
    • LAST() - Returns the last value
    • MAX() - Returns the largest value
    • MIN() - Returns the smallest value
    • SUM() - Returns the sum
     Aggregate functions often need an added GROUP BY statement.
    The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns.
    SELECT Customer,SUM(OrderPrice) FROM Orders
    GROUP BY Customer

    GROUP BY More Than One Column

     SELECT Customer,OrderDate,SUM(OrderPrice) FROM Orders
    GROUP BY Customer,OrderDate


    The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions. 

    SELECT Customer,SUM(OrderPrice) FROM Orders
    GROUP BY Customer
    HAVING SUM(OrderPrice)<2000 

    SELECT Customer,SUM(OrderPrice) FROM Orders
    WHERE Customer='Hansen' OR Customer='Jensen'
    GROUP BY Customer
    HAVING SUM(OrderPrice)>1500 
    Server.Transfer Vs. Response.Redirect
    We all uses Server.Transfer() and Response.Redirect() interchangeably. But what is the difference between two methods. Which one to use over other? We are just trying to get the advantages and disadvantages of both. So read down the article to get grasp of knowledge.
    [1] Server.Transfer: Redirection to another URL is performed on server side. Transfer happens on server side and hence consume more resources on server side.
    Response.Redirect: Requires a round trip to the browser running on user's computer. And then navigate to the URL specified. It increase overload on server by increasing requests to the server.
    For Example:
    You can understand it as your Web Application is running on the server, and then it comes to line Response.Redirect().This line tells the browser to make request to another page. So this is round trip to the browser.
    While in case of Server.Transfer() page transfers directly to the URL specified without going to the browser.
    [2] Server.Transfer: Maintains the original URL in the browser. So sometimes if user refresh page it makes confusion or error.
    Response.Redirect: URL changes as the target URL specified.
    [3] Server.Transfer: Method has a second parameter - bool preserveForm. If you set this to True, using a statement such as Server.Transfer("~/Target.aspx", True), the existing query string and any form collections will still be available to the transfering target page.
    Response.Redirect: Method has a second parameter - bool endResponse. If you set this to True, using a statement such as Response.Redirect("~/Target.aspx", True), the execution of the current page terminates.
    For Example:
    If Source.aspx has a TextBox control called txtSource and you transferred to Target.aspx with the preserveForm parameter set to True, you will be able to retrieve the value of the original page(Source.aspx) TextBox control by referencing Request.Form("txtSource").
    [4] Server.Transfer: Method cannot redirect to a different server itself.
    Response.Redirect: Method can redirect to a different server also.
    Varchar And Varchar(2)
    VARCHAR is an abbreviation for variable-length character string. It's a string of text characters that can be as large as the page size for the database table holding the column in question. The size for a table page is 8,196 bytes, and no one row in a table can be more than 8,060 haracters. This in turn limits the maximum size of a VARCHAR to 8,000 bytes.
    The "N" in NVARCHAR means uNicode. Essentially, NVARCHAR is nothing more than a VARCHAR that supports two-byte characters. The most common use for this sort of thing is to store character data that is a mixture of English and non-English symbols — in my case, English and Japanese.
    The key difference between the two data types is how they're stored. VARCHAR is stored as regular 8-bit chacter data. But NVARCHAR strings are stored in the database as UTF-16 — 16 bits or two bytes per character, all the time — and converted to whatever codepage is being used by the database connection on output (typically UTF-8). That said, NVARCHAR strings have the same length restrictions as their VARCHAR cousins — 8,000 bytes. However, since NVARCHARs use two bytes for each character, that means a given NVARCHAR can only hold 4,000 characters (not bytes) maximum. So, the amount of storage needed for NVARCHAR entities is going to be twice whatever you'd allocate for a plain old VARCHAR.
    Because of this, some people may not want to use NVARCHAR universally, and may want to fall back on VARCHAR — which takes up less space per row — whenever possible.
    Here's an example of how to mix and match the use of the two types. Let's say we have a community website where people log in with a username, but can also set a public "friendly" name to be more easily identified by other users. The login name can be a VARCHAR, which means it must be 8-bit ASCII (and it can be constrained further to conventional alphanumerics with a little more work, typically on the front end). The friendly name can be an NVARCHAR to allow Unicode entities. This way you're allowing support for Unicode, but only in the place where it matters most — both for the users, and where the extra storage space is going to be put to the best possible use.
    1.One fairly major change to both VARCHAR and NVARCHAR in SQL Server 2005 is the creation of the VARCHAR(MAX) and NVARCHAR(MAX) data types. If you create a VARCHAR(MAX) column, it can hold up to 2^31 bytes of data, or 2,147,483,648 characters; NVARCHAR(MAX) can hold 2^30 bytes, or 1,073,741,823 characters.
    2.These new data types are essentially replacements for the Large Object or LOB data types such as TEXT and NTEXT, which have a lot of restrictions. They can't be passed as variables in a stored procedure, for instance. The (MAX) types don't have those restrictions; they just work like very large string types. Consequently, if you're in the process of re-engineering an existing data design for SQL Server 2005, it might make sense to migrate some (although not all!) TEXT / NTEXT fields to VARCHAR(MAX) / NVARCHAR(MAX) types when appropriate.
    3.The big difference between VARCHAR and NVARCHAR is a matter of need. If you need Unicode support for a given data type, either now or soon enough, go with NVARCHAR. If you're sticking with 8-bit data for design or storage reasons, go with VARCHAR. Note that you can always migrate from VARCHAR to NVARCHAR at the cost of some room -- but you can't go the other way 'round. Also, because NVARCHAR involves fetching that much more data, it may prove to be slower depending on how many table pages must be retrieved for any given operation.
    4.An nvarchar column can store any Unicode data. A varchar column is restricted to an 8-bit codepage. Some people think that varchar should be used because it takes up less space. I believe this is not the correct answer. Codepage incompatabilities are a pain, and Unicode is the cure for codepage problems. With cheap disk and memory nowadays, there is really no reason to waste time mucking around with code pages anymore.
    5.All modern operating systems and development platforms use Unicode internally. By using nvarchar rather than varchar, you can avoid doing encoding conversions every time you read from or write to the database. Conversions take time, and are prone to errors. And recovery from conversion errors is a non-trivial problem.
    6.If you are interfacing with an application that uses only ASCII, I would still recommend using Unicode in the database. The OS and database collation algorithms will work better with Unicode. Unicode avoids conversion problems when interfacing with other systems. And you will be preparing for the future. And you can always validate that your data is restricted to 7-bit ASCII for whatever legacy system you're having to maintain, even while enjoying some of the benifits of full Unicode storage.
    7.You're right. nvarchar stores Unicode data while varchar stores single-byte character data. Other than storage differences (nvarchar requires twice the storage space as varchar), which you already mentioned, the main reason for preferring nvarchar over varchar would be internationalization (i.e. storing strings in other languages).
    8.If it was just a storage issue then you're probably right - especially for small apps - but here is a list of reasons you may want to choose varchar over nvarchar.
        * Your app is interfacing with an older app that uses ascii data. If you store your data as ascii too there is one less thing to go wrong when you communicate with the older app.
        * You are storing vast numbers of records - half the size means you can backup your data twice as quickly and store twice as many backups.
        * If you are ever going to perform searches on your data then half the size means your searches will run twice as fast.
        * You know you will only need ascii data. You want your app to warn you if you're trying to store something else because it probably means something much worse is going on somewhere else!
    I would say, it depends.
    If you develop a desktop application, where OS works in unicode (like all current windows systems) and language does natively support unicode (default strings are unicode, like in Java or C#), then go nvarchar.
    If you develop a web application, where strings come in as UTF8, and language is PHP, which still does not support unicode natively (in versions 5.x), then varchar will probably be a better choice.
    Function and Storeprocedure
    1> Functions can be called from procedure where as procedures cannot be called from function.
    2> Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.
    3> Function must return one and only one value where as Procedure can return any number of values (0 to n).
    4> Function can only have input parameters only where as Procedure can have input as well as output parameters.
    5> Function can have only select statement in it where as a Procedure can have select as well as DML statement in it.
    6> Procedure can use try-catch block to handle exception where as try-catch block cannot be used in a function.
    7> Function can be used in a assignment operation where as Procedure can not be part of assignment operation.
    :1. Procedures are parsed and compiled. They are stored in compiled format in the database where as Functions are compiled and excuted runtime.Note: I don't agree that functions don't accept more than one parameters. Both functions and procedures can be parameterized with multiple parameters.
    Dataset copy and clone
    There is a huge difference between dataset clone and dataset copy. Though, a clone means a copy of something, but the results here are different. The methods involved between the two are quite different as well. By the method of dataset clone, the structure of the dataset is copied which contains datatable schemes and constraints. It actually does not copy any relevant data. On the other hand, the dataset copy has the ability to copy both the structure and the data of the program. These kinds of methods are used in the computer programming languages such as C#. The dataset is in a form of rows and columns in a tubular form which contain valuable data that is to be input in the programming language. It is helpful in creating programs for the computer
    .
    Using Dataset.clone() creates new instance of the same object.
    Using Dataset.copy() copies content of data to another object wihtout creating new instance.
    Dataset.clone() copies the structure of the dataset including all data table schemas relations and constraints. and Dataset.copy() copies the structure with data of the Dataset.
    Thread and process
    A process is a collection of virtual memory space, code, data, and system resources.
    A thread is code that is to be serially executed within a process.
    A processor executes threads, not processes, so each application has at least one process, and a process always has at least one thread of execution, known as the primary thread.
    A process can have multiple threads in addition to the primary thread
    Thread – is stream of executable code within process. They are light weight process.
    All thread with in a process share process instruction,code & data segment,open file descriptor,signal handler,userID and GroupID.
    Thread has its own set of register including program counter,stack pointer
    The major difference between threads and processes is
    1.Threads(Light weight Processes) share the address space of the process that created it
    1 processes have their own address.
    2.Threads have direct access to the data segment of its process;
    2processes have their own copy of the data segment of the parent process.
    3.Threads can directly communicate with other threads of its process;
    3processes must use interprocess communication to communicate with sibling processes.
    4.Threads have almost no overhead;
    4processes have considerable overhead.
    5.New threads are easily created;
    5 new processes require duplication of the parent process.
    6.Threads can exercise considerable control over threads of the same process;
    6processes can only exercise control over child processes.
    7.Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process;
    7changes to the parent process does not affect child processes.
    If we consider running a word processing program to be a process, then the auto-save and spell check features that occur in the background are different threads of that process which are all operating on the same data set
    Value type and reference type
    Value Types:
    In C#, all the "things" declared with the following list of type declarations are Value types (because they are from System.ValueType):
        * bool
        * byte
        * char
        * decimal
        * double
        * enum
        * float
        * int
        * long
        * sbyte
        * short
        * struct
        * uint
        * ulong
        * ushort
    Reference Types:
    All the "things" declared with the types in this list are Reference types (and inherit from System.Object... except, of course, for object which is the System.Object object):
        * class
        * interface
        * delegate
        * object
        * string
    Difference between dataadapter and datareader
    DateReader is an forward only and read only cursor type if you are accessing data through DataRead it shows the data on the web form/control but you can not perform the paging feature on that record(because it's forward only type). Reader is best fit to show the Data (where no need to work on data)
    DataAdapter is not only connect with the Databse(through Command object) it provide four types of command (InsertCommand UpdateCommand DeleteCommand SelectCommand) It supports to the disconnected Architecture of .NET show we can populate the records to the DataSet. where as Dataadapter is best fit to work on data.
    DataAdapter is Bridge between Database and DataSet.
    DataReader
    Works in Connected Mode
    Forward Only Read Only
    DataAdapter
    Works in Disconnected Mode
    Both Side Movements Read/Write
    Data Reader: It take the data sequentially from the command object and requies the connection should be open while it is getting data.
    Data Adapter: It fetch all the required data from database and pass it to DataSet.
    DataSet: It get all the required data from Data Adapter. It contains data in the form of Data Table.
    DataSet : it is a disconnected Articeture...
    Connected Architecture : Means that while SqlDataReader reads the data from database and also reading data from SqlDataReader to any variable the connection to database should be open. Also once you read some data from SqlDataReader you should save them becouse it is not possible to go back and read it again.
    DataReader : it is a Connected Articeture...
    Disconnected Architecture : It is followed by Dataset. In this once the data has been read by Dataset from SqlDataAdapter we can close the connection to database and retirve the data from Dataset where ever we want. Dataset hold the data in the form of table and do not interact with Datasouse.
    Difference between varchar and nvarchar
    Varchar-- only characters
    nvarchar--Unicode character ,Take the required memory space.
    char--Fixed the memory space what we assign.for single character also it will take the whole memory space.

    Difference between Build ,rebuild ,start , start without debugging  

    Your source code is just a text file - it can't run on it's own. To make something that the computer understands, it needs to be compiled. In VB.Net there are two stages of compilation. Building the source code is the first step, it creates more source code! This source code, called IL (Intermediate language), is common between all the .Net languages. Your .exe files contain this source code, and some other important things. When you run the .exe, the .Net Framework compiles parts of the code as and when it is needed into something that the computer can understand and run, this is the second compilation and is known as JIT compiling (Just-In-Time).
    There are two types of build. A Release build is optimised and it does not contain any additional code that is created to allow you to debug the program in visual studio. A Debug build is not optimised, and it contains additional code that is used when you are debugging your program.
    Build: compile the vb.net code into IL code. This will create/update the exe or dll, but it doesn't start the program.
    Rebuild: Like build, but only compiles the code that has changed since you last compiled. Faster.
    Start: Build the Debug version of the code, and start the program.
    Start without debugging: Build the Release version of the code and start the program.
    Scripting languages And Programming language
    Scripting languages code are interpreted at run-time. This means that every time we want to run the program, a separate program needs to read the code, interpret it, and then follow the instructions in the code. (eg. PHP, ASP, JSP, JavaScript, VBScript etc.)
    Programming language code are compiled before it is run. Once it is compiled, it can run any number of times. Because compiled code are already been interpreted into machine language, so it is typically faster than scripting language. (eg. C, C++, C# etc.) 

    Differece between bind and eval 

    To bind the database column value to the child control in a gridview, we can either use Bind() or Eval() methods.



    <ItemTemplate>

                            <asp:Label ID="lblDOB" runat="server" Text='<%# Bind("DOB") %>'></asp:Label>

    </ItemTemplate>



    If you see the above code, we have used Bind() to bind DOB to the text property of Label control. Using Eval in the place of Bind will also work.



    Eval() and Bind() methods


    You can use the Eval method when the control will only display values.It is used to define one-way (read-only) binding. If you just need to display data on the screen from DataSource it’s enough to use Eval. It’s something like read-only method from DataSource.
    Eval is a protected method defined on the TemplateControl class, from which the Page class is derived. 
    Eval is used for unidirectional (readonly) data binding, while Bind is for bi-directional (editable) databinding.

    You can use the Bind method when users can modify a data value - that is, for data edit/update/view scenarios called two-way databinding. 
    The Bind function is used for two-way (updatable) binding
    But if you need to edit data inside of Grid you have to use Bind method. Because it provides two way binding you can read data from DataSource and you can write data back.

    Usually you have to use this methods if you need to quickly develop some WebPages and display and edit data from one table or simple view. 
    Bind is a new ASP.NET 2.0 databinding keyword. It's not a method of any specific class.


    <asp:TemplateField HeaderText="URL">

                                <EditItemTemplate>

                                    <asp:TextBox ID="txtURL" Width="100%" Text='<%# Bind("URL")%>' runat="server"></asp:TextBox>

                                </EditItemTemplate>

                                <ItemTemplate>

                                    <asp:HyperLink ID="hplURL" Text='<%# Bind("URL") %>' NavigateUrl='<%# Bind("URL") %>' runat="server">[hplURL]</asp:HyperLink>

                                </ItemTemplate>
                            </asp:TemplateField>

    What is the difference between out and ref in C#? 

     Each parameter passing mode is designed to apply to a slightly different programming scenario. The important difference between out and ref parameters is the definite assignment rules used by each.
    The caller of a method which takes an out parameter is not required to assign to the variable passed as the out parameter prior to the call; however, the callee is required to assign to the out parameter before returning.
    Here's a simple example:

    class OutExample
    {
    // Splits a string containing a first and last name separated
    // by a space into two distinct strings, one containing the first name and one containing the last name

    static void SplitName(string fullName, out string firstName, out string lastName)
    {
    // NOTE: firstName and lastName have not been assigned to yet. Their values cannot be used.
    int spaceIndex = fullName.IndexOf(' ');
    firstName = fullName.Substring(0, spaceIndex).Trim();
    lastName = fullName.Substring(spaceIndex).Trim();
    }

    static void Main()
    {
    string fullName = "Yuan Sha";
    string firstName;
    string lastName;

    // NOTE: firstName and lastName have not been assigned yet. Their values may not be used.
    SplitName(fullName, out firstName, out lastName);
    // NOTE: firstName and lastName have been assigned, because the out parameter passing mode guarantees it.

    System.Console.WriteLine("First Name '{0}'. Last Name '{1}'", firstName, lastName);
    }
    }

    One way to think of out parameters is that they are like additional return values of a method. They are very convenient when a method returns more than one value, in this example firstName and lastName. Out parameters can be abused however. As a matter of good programming style if you find yourself writing a method with many out parameters then you should think about refactoring your code. One possible solution is to package all the return values into a single struct.

    In contrast ref parameters are considered initially assigned by the callee. As such, the callee is not required to assign to the ref parameter before use. Ref parameters are passed both into and out of a method.

    Here's an example:

    class RefExample
    {
    static object FindNext(object value, object[] data, ref int index)
    {
    // NOTE: index can be used here because it is a ref parameter
    while (index < data.Length)
    {
    if (data[index].Equals(value))
    {
    return data[index];
    }
    index += 1;
    }
    return null;
    }

    static void Main()
    {
    object[] data = new object[] {1,2,3,4,2,3,4,5,3};

    int index = 0;
    // NOTE: must assign to index before passing it as a ref parameter
    while (FindNext(3, data, ref index) != null)
    {
    // NOTE: that FindNext may have modified the value of index
    System.Console.WriteLine("Found at index {0}", index);
    index += 1;
    }

    System.Console.WriteLine("Done Find");
    }
    }


    1) out parameters return compiler error if they are not assigned a value in the method. Not such with ref parameters.

    2) out parameters need not be initialized before passing to the method, whereas ref parameters need to have an initial value before they are passed to a method.

    Ref paramenter is nothing but in & out parameter.
    Out is only out parameter.

    Convert.ToString() and ToString()
    There is a simple but important difference between these three…
    ToString() raise exception when the object is null
    So in the case of object.ToString(), if object is null, it raise NullReferenceException.
    Convert.ToString() return string.Empty in case of null object

                 object a = null;
                Console.Write(Convert.ToString(a));
                Console.WriteLine(a.ToString());->raise exception
                Console.ReadLine();

    Whats the difference between Classic ASP and ASP.NET? 

    Major difference: Classic ASP is Interpreted. ASP.NET is Compiled. If code is changed, ASP.NET recompiles, otherwise does'nt.
    Other differences: ASP works with VB as the language. ASP.NET works with VB.NET & C# as the languages (Also supported by other languages that run on the .NET Framework).
    ASP.NET is the web technology that comes with the Microsoft .NET Framework. The main process in ASP.NET is called aspnet_wp.exe that accesses system resources. ASP.NET was launched in 2002 with version 1.0. Subsequent versions are 1.1 and version 2.0. ASP.NET is built up using thousands of objects, ordered in the System namespace. When an ASP.NET class is compiled, its called an assembly.
    In Classic ASP, complex functionalities are achieved using COM components, that are nothing but component objects created using VB 6, C++ etc, and are usually in a DLL format. These components provide an exposed interface to methods in them, to the objects that reference these components. Last version of classic ASP is version 3.0. ASP has 7 main objects - Application, ASPError, ObjectContext, Request, Response, Server, Session.

    Difference Between Dictionary and Hashtable

    Dictionary is typed (sо valuetypes dоn’t need bоxing), a Hashtable isn’t (sо valuetypes need bоxing). Hashtable has a nicer way оf оbtaining a value than dictionary IMHО, because it always knоws the value is an оbject. Thоugh if yоu’re using .NET 3.5, it’s easy tо write an extensiоn methоd fоr dictionary tо get similar behaviоr.
    The Hashtable class is a specific type оf dictionary class that uses an integer value (called a hash) tо aid in the stоrage оf its keys. The Hashtable class uses the hash tо speed up the searching fоr a specific key in the cоllectiоn. Every оbject in .NET derives frоm the Оbject class. This class suppоrts the GetHash methоd, which returns an integer that uniquely identifies the оbject. The Hashtable class is a very efficient cоllectiоn in general. The оnly issue with the Hashtable class is that it requires a bit оf оverhead, and fоr small cоllectiоns (fewer than ten elements) the оverhead can impede perfоrmance.

    There is оne mоre impоrtant difference between a HashTable and Dictionary. If yоu use indexers tо get a value оut оf a HashTable, the HashTable will successfully return null fоr a nоn-existent item, whereas the Dictionary will thrоw an errоr if yоu try accessing a item using a indexer which dоes nоt exist in the Dictionary.

    The HashTable is the base class that is weakly typed; the DictionaryBase abstract class is strоnly typed and uses internally a HashTable.

    A strange thing noticed abоut Dictionary is, when we add the multiple entries in Dictionary, the оrder in which the entries are added is maintained. Thus if you apply a fоreach оn the Dictionary, you will get the recоrds in the same оrder you have inserted them.

    Whereas, this is nоt true with nоrmal HashTable, when you add same recоrds in Hashtable the оrder is nоt maintained. If ’Dictionary is based оn Hashtable’ is true, why Dictionary maintains the оrder but HashTable dоes nоt?

    As tо why they behave differently, it’s because Generic Dictionary implements a hashtable, but is nоt based оn System.Cоllectiоns.Hashtable. The Generic Dictionary implementatiоn is based оn allоcating key-value-pairs frоm a list. These are then indexed with the hashtable buckets fоr randоm access, but when it returns an enumeratоr, it just walks the list in sequential оrder – which will be the оrder оf insertiоn as lоng as entries are nоt re-used.

    Hash table -                                                                        Dictionary-
    ---------------------------------------------------------------------------------------------
    Strongly type.                                                                     Weakly type
    Store value object type
    Unboxing need

    Difference between Control state and view state


    1. Control state, introduced in ASP.NET version 2.0, is similar to view state but functionally independent of view state. 

    2. A page developer can disable view state for the page or for an individual control for performance. However, control state cannot be disabled. 

    3. Control state is designed for storing a control's essential data that must be available on postback to enable the control to function even when view state has been disabled.

    4. By default,the ASP.NET page framework stores control state in the page in the same hidden element in which it stores view state. 

    5. Even if view state is disabled, or when state is managed using Session, control state travels to the client and back to the server in the page.

    6. On postback, ASP.NET deserializes the contents of the hidden element and loads control state into each control that is registered for control state. 

    7. Use control state only for small amounts of critical data that are essential for the control across postbacks.Do not use control state as an alternative to view state

    Difference between an abstract method & virtual method:

    Virtual method has an implementation & provide the derived class with the option of overriding it. Abstract method does not provide an implementation & forces the derived class to override the method.

    important Notes:

    (a)Any Class with abstract method or property in it must be declared abstract

    (b)Attempting to instantiate an object of an abstract class retults in a compilation error


    Example:


    Shape m_MyShape = new Shape(); //it is Wrong to that.
    
    But we can do that.
    Shape m_MyShape = new Circle(); // True
    
    Or
    Shape m_MyShape; 
    /*
    
    declare refrences only, and the refrences can refer to intances of
    any concrete classes derived from abstract class
    */
    
    Circle m_MyCircle = new Circle();
    m_MyShape  = m_MyCircle; // Also True
    
    (d)An abstract class can have instance data and non-abstract methods -including constructors-.


    Difference between String.Empty, Empty Quotes and String.length

    At many point of time I had to make a checking for empty string. I started thinking about the difference between “” and string.empty. and which one is a better way to check if the string is empty or not.
    The difference between string.Empty and “” is very small. String.empty will not create any object while “” will create a new object in the memory for the checking. Hence string.empty is better in memory management.

    But the comparison with string.length == 0 will be even faster and the better way to check for the empty string.

    And I also have a bias for checking with string.length in this case. But do not forget to make a checking for null value if you are also expecting null value in the comparison.

    String.Empty is a readonly field, while "" is a constant
    Consider this code snippet.

    private void button1_Click(object sender, EventArgs e)
            {
                string s = textBox1.Text;
                switch (s)
                {
                    case String.Empty:
                        MessageBox.Show("blank");
                        break;
                }
            }
    //Compiler will generate an error
    //A constant value is expected
    //So, if we use "" in place of String.Empty, no error will be generated.