I, Me, Myself

My photo
Hyderabad, Hindhu/AndhraPradesh, India
CoOl,jOvial,strAight fOrward

Search

DotNet

DOTNET QUESTIONS AND ANSWERS

1.       What is .Net Framework?
The .NET Framework is an integral Windows component that supports building and running the next generation of applications and XML Web services. The .NET Framework is designed to fulfill the following objectives
The .NET Framework has two main components: the common language runtime and the .NET Framework class library. The common language runtime is the foundation of the .NET Framework. You can think of the runtime as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety and other forms of code accuracy that promote security and robustness. In fact, the concept of code management is a fundamental principle of the runtime. Code that targets the runtime is known as managed code, while code that does not target the runtime is known as unmanaged code. The class library, the other main component of the .NET Framework, is a comprehensive, object-oriented collection of reusable types that you can use to develop applications ranging from traditional command-line or graphical user interface (GUI) applications to applications based on the latest innovations provided by ASP.NET, such as Web Forms and XML Web services

2.       ASP.Net life Cycle?
The Life Cycle of a page when requested for the first time:
Initializing: During this phase, the server creates an instance of the server control
Loading: During this phase, the instance of the control is loaded onto the page object in which it is defined.
PreRendering: During this phase, the control is updated with the changes made to it. This prepares the control for rendering.
Saving: During this phase, the state information of the control is saved. For example, if a value is set for the control during the Load event, it is embedded in the HTML tag that will be returned to the browser.
Rendering: During this phase, the server creates the corresponding HTML tag for the control.
Disposing: During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.
Unloading: During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is the final event in the life cycle of a server control

3.       Assembly’s
Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.
Assemblies are a fundamental part of programming with the .NET Framework. An assembly performs the following functions:
·         It contains code that the common language runtime executes. Microsoft intermediate language (MSIL) code in a portable executable (PE) file will not be executed if it does not have an associated assembly manifest. Note that each assembly can have only one entry point (that is, DllMain, WinMain, or Main).
It forms a reference scope boundary. The assembly's manifest contains assembly metadata that is used for resolving types and satisfying resource requests. It specifies the types and resources that are exposed outside the assembly. The manifest also enumerates other assemblies on which it depends.
Assemblies can be static or dynamic. Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in portable executable (PE) files. You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.
There are several ways to create assemblies. You can use development tools, such as Visual Studio 2005, that you have used in the past to create .dll or .exe files. You can use tools provided in the Windows Software Development Kit (SDK) to create assemblies with modules created in other development environments. You can also use common language runtime APIs, such as to Refelection.emit  create dynamic assemblies.
GAC & installation Files
Each computer where the common language runtime is installed has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.
You should share assemblies by installing them into the global assembly cache only when you need to. As a general guideline, keep assembly dependencies private, and locate assemblies in the application directory unless sharing an assembly is explicitly required. In addition, it is not necessary to install assemblies into the global assembly cache to make them accessible to COM interop or unmanaged code.
Ex : gacutil [options] [assemblyName | assemblyPath | assemblyListFile]

4.       MSIL
When compiling to managed code, the compiler translates your source code intoMicrosoft intermediate language (MSIL),which is a CPU-independent set of instructions that can be efficiently converted to native code. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. Microsoft intermediate language (MSIL) is a language used as the output of a number of compilers and as the input to a just-in-time (JIT) compiler. The common language runtime includes a JIT compiler for converting MSIL to native code.
5.       Compilers
6.       JIT
7.       Runtime Compilers and debug compilers
8.       Web.config & Machine .config
9.       Authentication a & authorization
10.   Events ,event bubbling
11.   String and string builder
12.   WCF and WCF overloading
13.   Linq to Sql
14.   SharePoint server overview
15.   WSS and Moss
16.   Sqlconnection flow
17.   Cursors,triggers,indexes

Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of the typical SQL commands that operate on all the rows in the set at one time. For example, you can use cursor to include a list of all user databases and make multiple operations against each database by passing each database name as a variable
SQL Server is very good at handling sets of data. For example, you can use a single UPDATE statement to update many rows of data. There are times when you want to loop through a series of rows a perform processing for each row. In this case you can use a cursor.



Creates a DML, DDL, or logon trigger. A trigger is a special kind of stored procedure that automatically executes when an event occurs in the database server. DML triggers execute when a user tries to modify data through a data manipulation language (DML) event. DML events are INSERT, UPDATE, or DELETE statements on a table or view.

18.   CCW & RCW
19.   Delegate
A delegate can hold reference/s to one more more functions and invoke them as and when needed.
A delegate needs the method's name and its parameters (input and output variables) when we create a delegate. But delegate is not a standalone construction. it's a class. Any delegate is inherited from base delegate class of .NET class library when it is declared. This can be from either of the two classes
from System.Delegate or System.MulticastDelegate.
If the delegate contains a return type of void, then it is automatically aliased to the type of System.MulticastDelegate. This can support multiple functions with a += operator. If the delegate contains a non-void return type then it is aliased to System.Delegate class and it cannot support multiple methods.

20.   Reversing string in C#

using System;
 
static class StringHelper
{
    /// 
    /// Receives string and returns the string with its letters reversed.
    /// 
    public static string ReverseString(string s)
    {
        char[] arr = s.ToCharArray();
        Array.Reverse(arr);
        return new string(arr);
    }
}
21.   Magic Tables
There are 2 Magic Tables in SQL server Inserted and Deleted.
These are mantained by SQL server for Internal processing whenever an update, insert of delete occur on a table. However, we can refere these tables in a Trigger.
Whenever an update table statement is fired SQL server mantains the original row before updation in a deleted table and New (updated )row in a Inserted Table.

Same is the case when an insert is fired Only Inserted table is populated with inserted Row.
and when Delete table statement is fired Deleted table is populated with the deleted row.
1. Inserted
     Insert
     Update
2. Deleted

22. Views
23.   State management
A new instance of the Web page class is created each time the page is posted to the server. In traditional Web programming, this would typically mean that all information associated with the page and the controls on the page would be lost with each round trip. For example, if a user enters information into a text box, that information would be lost in the round trip from the browser or client device to the server.
To overcome this inherent limitation of traditional Web programming, ASP.NET includes several options that help you preserve data on both a per-page basis and an application-wide basis. These features are as follows:
·         View state
·         Control state
·         Hidden fields
·         Cookies
·         Query strings
·         Application state
·         Session state
·         Profile Properties
View state, control state, hidden fields, cookies, and query strings all involve storing data on the client in various ways. However, application state, session state, and profile properties all store data in memory on the server. Each option has distinct advantages and disadvantages, depending on the scenario.
View State
The view state  property provides a dictionary object for retaining values between multiple requests for the same page. This is the default method that the page uses to preserve page and control property values between round trips.
When the page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field, or multiple hidden fields if the amount of data stored in the view state property exceeds the specified value in the Max pagestate field length property. When the page is posted back to the server, the page parses the view-state string at page initialization and restores property information in the page.
ViewState["color"] = "red";
b. Control State – If you create a custom control that requires view state to work properly, you should
use control state to ensure other developers
 don’t break your control by disabling view state. 



c. Hidden fields – Like view state, hidden fields store data in an HTML form without displaying 
it in the user's browser.
he data is available only when the form is processed. 



d. Cookies – Cookies store a value in the user's browser that the browser sends
 with every page request to the same server. 
Cookies are the best way to store state data that 
must be available for multiple Web pages on a web site. 



e. Query Strings - Query strings store values in the URL that are visible 
to the user. Use query strings when you want a 
user to be able to e-mail or instant message state data with a URL. 



2. Server – Side State Management 

a. Application State - Application State information is available to all pages, regardless of which
 user requests a page. 



b. Session State – Session State information is available to all pages opened by a 
user during a single visit. 



Both application state and session state information is lost when the application restarts.
 To persist user data between 
pplication restarts, you can store it using profile properties. 

24.   How to call JavaScript function in code behind?
 Clientmanager.registerstartupscript();
25.    Static class and static methods
A static constructor is only called one time, and a static class remains in memory for the lifetime of the application domain in which your program resides. 


What is Polymorphism?
Polymorphism means same operation may behave differently on different classes.
Example of Compile Time Polymorphism: Method Overloading
Example of Run Time Polymorphism: Method Overriding

Example of Compile Time Polymorphism

Method Overloading
- Method with same name but with different arguments is called method overloading.
- Method Overloading forms compile-time polymorphism.
- Example of Method Overloading:
class A1
{
void hello()
{ Console.WriteLine(“Hello”); }

void hello(string s)
{ Console.WriteLine(“Hello {0}”,s); }
}


Example of Run Time Polymorphism

Method Overriding
- Method overriding occurs when child class declares a method that has the same type arguments as a method declared by one of its superclass.
- Method overriding forms Run-time polymorphism.
- Note: By default functions are not virtual in C# and so you need to write “virtual” explicitly. While by default in Java each function are virtual.
- Example of Method Overriding:
Class parent
{
virtual void hello()
{ Console.WriteLine(“Hello from Parent”); }
}

Class child : parent
{
override void hello()
{ Console.WriteLine(“Hello from Child”); }
}

static void main()
{
parent objParent = new child();
objParent.hello();
}
//Output
Hello from Child.



Value type and reference type
Get and Post Method
Get Vs Post Method

Get Vs Post Method to send data to the server

Get and Post are methods used to send data to the server:
With the Get method, the browser appends the data onto
the URL. With the Post method, the data is sent
as "standard input."

Use GET:
- during development for debugging purposes (although in ASP.NET it's
   also easy to see what has been sent through POST).
- if you want your visitors to be able to bookmark the submitted pages
- if you want to refer to submitted pages using hyperlinks

Use POST:
- for forms with password fields
- for large forms or forms with large text fields

Please note that web forms in ASP.NET use POST by default.

It can be changed into GET, but only for small forms. Web forms can post a lot
of data, especially when ViewState is involved.
Access modifiers
Classes
and structs can be restricted so that only the program or namespace they are declared in may use them. Class members can be restricted so that only derived classes can use them, or restricted so that only classes within the current namespace or program can use them. Access modifiers are keywords added to the class, struct, or member declaration to specify these restrictions. So in a nutshell access modifiers are keywords which control the visibility of class members and other code constructs.

The access modifiers in .NET are
1. public

2. private

3. protected

4. internal

5. protected internal
public

Public means visible to everyone and everywhere.

Access cases
1. By objects of the class

2. By derived classes
private

Private means hidden and usable only by the class itself. No code using a class instance can access a private member and neither can a derived class. Information or functionality that will not be needed or has no meaning outside of the context of a specific class should be made private.

Access cases
1. Cannot be accessed by object

2. Cannot be accessed by derived classes
protected

Protected members are similar to private ones in that they are accessible only by the containing class. However, protected members also may be used by a descendant class. So members that are likely to be needed by a descendant class should be marked protected.

Access cases
1. Cannot be accessed by object

2. By derived classes
internal

Internal are public to the entire assembly but private to any outside assemblies. Internal is useful when you don't want to allow other assemblies to have the functionality.

Access cases

In same assembly (public).
1. By objects of the class

2. By derived classes
In other assembly (internal)
1. Cannot be accessed by object

2. Cannot be accessed by derived classes
protected internal

Finally, we have the only compound access modifier allowed in .NET. Members marked as protected internal may be accessed only by a descendant class that's contained in the same assembly as its base class. You use protected internal in situations where you want to deny access to parts of a class' functionality to any descendant classes found in other
applications.

Note: that it's illegal to combine two access modifiers for a class but can only be applied to the members.

Access cases

In same assembly (protected).
1. Cannot be accessed by object

2. Can be accessed by a derived classes
In other assembly (internal)
1. Cannot be accessed by object

2. Cannot be accessed by derived classes


SqlServer Reporting Services (SSRS)
SSRS 2005 is the latest version of SQL Reporting Services, and ships with all versions of SQL Server 2005. SSRS allows you to quickly and easily create reports from multiple database sources. The finished reports can be presented directly from the reporting services website, or they can be displayed in your web- or Windows-based applications. Reports can be exported to multiple formats, including comma delimited text, XML, portable document format (pdf) and Microsoft Excel.
Crystal Reports:


Formula Fields
Parameter Fields
GroupName Fields
Running Total Fields
Special Fields
Unbound Fields

What is Global. asax
Global.asax is a file used to declare application-level events and objects. Global.asax is the ASP.NET extension of the ASP Global.asa file. Code to handle application events (such as the start and end of an application) reside in Global.asax. Such event code cannot reside in the ASP.NET page or web service code itself, since during the start or end of the application, its code has not yet been loaded (or unloaded). Global.asax is also used to declare data that is available across different application requests or across different browser sessions. This process is known as application and session state management.

The Global.asax file must reside in the IIS virtual root. Remember that a virtual root can be thought of as the container of a web application. Events and state specified in the global file are then applied to all resources housed within the web application. If, for example, Global.asax defines a state application variable, all .aspx files within the virtual root will be able to access the variable.

Like an ASP.NET page, the Global.asax file is compiled upon the arrival of the first request for any resource in the application. The similarity continues when changes are made to the Global.asax file: ASP.NET automatically notices the changes, recompiles the file, and directs all new requests to the newest compilation.
Validation Controls
RequiredFieldValidator
RangeValidator
RegularExpression validator
ComapareValidator
Custom Validator
validation Summary
Differences Between Varchar and Nvarchar
Varchar means Variable-length Character string.
Nvarchar will store Unicode characters.Both will be used all most for the same purpose but with little difference.
Varchar will store the 8-bit data in database where as Nvarchar will be stored as 16-bit data in Database.
In Sql server 2005
nvarchar stores unicode data while varchar stores ascii data. They function identically but nvarchar takes up twice as much space.
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.
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.
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.
nvarchar stores data as unicode, so, if you're going to store multilingual data (more than one language) in a data column you need the N variant.

What is Caching?

Caching is a technique of persisting the data in memory for immediate access to requesting program calls. Many in the developer community consider caching as one of the features available to improve performance of Web applications.
ASP.NET Cookies Overview 
Cookies are associated with a Web site, not with a specific page, so the browser and server will exchange cookie information no matter what page the user requests from your site. As the user visits different sites, each site might send a cookie to the user's browser; the browser stores all the cookies separately.
Cookie Limitations

Most browsers support cookies of up to 4096 bytes. THerefore, cookies are best used to store small amounts of data, or even better,only an identifier such as a user ID. This user ID can then be used to identify the user and read user information from a database or other data store. In the case of Forms Authentication, the Forms cookie can store its own expiration time, as well as custom UserData (roles, preferences, etc.) This can eliminate the need to use Session to store small amounts of user-specific data. Forms auth cookies are normally encrypted. Cookie data can be compressed to allow storage of entire classes in .Net.
Browsers impose limitations on how many cookies your site can store on the user's computer. Most browsers allow only 20 cookies per site; if you try to store more, the oldest cookies are discarded. Some browsers also put an absolute limit, usually 300, on the number of cookies they will accept from all sites combined.

Managed Code
Code that you develop with a language compiler that targets the runtime is called managed code; it benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.

The runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used. Objects whose lifetimes are managed in this way are called managed data. Garbage collection eliminates memory leaks as well as some other common programming errors. If your code is managed, you can use managed data, unmanaged data, or both managed and unmanaged data in your .NET Framework application. Because language compilers supply their own types, such as primitive types, you might not always know (or need to know) whether your data is being managed.

GAC
There are several ways to deploy an assembly into the global assembly cache:
·         Use an installer designed to work with the global assembly cache. This is the preferred option for installing assemblies into the global assembly cache.
·         Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the Windows Software Development Kit (SDK).
·         Use Windows Explorer to drag assemblies into the cache.

  • gacutil [options] [assemblyName | assemblyPath | assemblyListFile]


Difference Between Dispose() and Finilize()
if you want to delete resources(objects) those are not using you should not worry about that garbage collecter implicitly call finalize() method and remove all such object but if you want to delete object forcefully(The larger object you want to delete after completeing task) than you can explicitly call dispose() method.

Cookies
there are two types of cookies persistent and non persistent cookies
----persistent cookies are permanent, example of persistent is remember me option used in most login pages.the user name and password are stored for long time
----non persistent cookies are temporarily used for storage, for short span of time

  
    
      regenerateExpiredSessionId="true" />
  
 
  cookieless="true "
  regenerateExpiredSessionId="true "
  timeout="30"
  sqlConnectionString="Data Source=MySqlServer;Integrated Security=SSPI;"
  stateNetworkTimeout="30"/>

Cursor Example

DECLARE @AccountID INT
Declare @UserName nvarchar(50)

DECLARE @UserCursor CURSOR
SET @UserCursor = CURSOR FOR
SELECT UserId,UserName
FROM Users
OPEN @UserCursor
FETCH NEXT
FROM @UserCursor INTO @AccountID,@UserName
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @AccountID
print @UserName
FETCH NEXT
FROM @UserCursor INTO @AccountID,@UserName
END
CLOSE @UserCursor
DEALLOCATE @UserCursor

Another Example


DECLARE @UserId int
Declare @UserName Nvarchar(50)
     
DECLARE c1 CURSOR READ_ONLY
FOR
SELECT UserId,UserName
FROM Users

OPEN c1

FETCH NEXT FROM c1
INTO @UserId,@UserName

WHILE @@FETCH_STATUS = 0
BEGIN

      PRINT @UserId
    Print @UserName
      FETCH NEXT FROM c1
      INTO @UserId,@UserName

END

CLOSE c1
DEALLOCATE c1
OOP & C#

   The skeleton of object - oriented programming is of course the
conceptsof class. This C# tutorialon OOPS explains classes and their importance in implementation of object oriented principles.
   Any language can be called object oriented if it has data and method that use data encapsulated in items named objects. An object oriented programming method has many advantages, some of them are flexibility and code reusability.
   All the programming languages supporting Object oriented Programming will be supporting these three main concepts:
  1. Encapsulation
  2. Inheritance
  3. Polymorphism
Encapsulation in C#:
   Encapsulationis process of keeping data and methods together inside objects. In this way developer must define some methods of object's interaction. In C# , encapsulation is realized through the classes. A Class can contain data structures and methods. Consider the following class.

public class Aperture
{
public Aperture()
{

}

protected double height;
protected double width;
protected double thickness;

public double GetVolume()
{
double volume = height*width*thickness;
if(volume<0)
return 0;
return volume;
}
}

   In this example we encapsulate some data such as height, width, thickness and method GetVolume. Other methods or objects can interact with this object through methods that have public access modifier. It must be done using . operator.
Inheritance in C#:
   In a few words, Inheritance isthe process of creation new classes from already existing classes. The inheritancefeature allows us to reuse some parts of code. So, now we have some derived class that inherits base class's members. Consider the following code snippet:

public class Door : Aperture
{
public Door() : base()
{

}

public bool isOutside = true;
}

   As you see to inherit one class from another, we need to write base class name after : symbol. Next thing that was done in code Door () constructor also inherits base class constructor. And at last we add new private field. All members of Aperture class are also in Door class. We can inherit all the members that has access modifier higher than protected.
Polymorphism in C#:
   Polymorphism is possibility to change behavior with objects depending of object's data type. In C# polymorphism realizes through the using of keyword virtual and override. Let look on the example of code:

public virtual void Out()
{
   Console.WriteLine("Aperture virtual method called");
}
//This method is defined in Aperture class.
public override void Out()
{
   Console.WriteLine("Door virtual method called");
}


   Now we need to re-define it in our derived Door class. The usage of virtual methods can be clarified when we creating an instance of derived class from the base class:
Aperture ap = new Door();
ap.Out();
   In such cases, the runtime keeps record of all the virtual function details in a table called VMT(Virtual Method Table) and then in runtime dynamically picks the correct version of the function to be used. Here it uses Out() method from derived class of course.
   To compile the attached example you need to run .NET console and run the next command: csc filename.cs .

Class
A user-defined data structure that groups properties and methods. Class doesn’t occupies memory.

Object

Instance of Class is called object. An object is created in memory using keyword “new”.

Difference between Struct and Class

  • Struct are Value type and are stored on stack, while Class are Reference type and are stored on heap.
  • Struct “do not support” inheritance, while class supports inheritance. However struct can implements interface.
  • Struct should be used when you want to use a small data structure, while Class is better choice for complex data structure.

Delegates

A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.
Sometimes, however, we don't want to call a function directly - we'd like to be able to pass it to somebody else so that they can call it. This is especially useful in an event-driven system such as a graphical user interface, when I want some code to be executed when the user clicks on a button, or when I want to log some information but can't specify how it is logged.

An interesting and useful property of a delegate is that it does not know or care about the class of the object that it references. Any object will do; all that matters is that the method's argument types and return type match the delegate's. This makes delegates perfectly suited for "anonymous" invocation.
The signature of a single cast delegate is shown below:
delegate result-type identifier ([parameters]);
where:
  • result-type: The result type, which matches the return type of the function.
  • identifier: The delegate name.
  • parameters: The Parameters, that the function takes.
·         public delegate int ButtonClickHandler (object obj1, object obj2)
·         This declaration defines a delegate named ButtonClickHandler, which will encapsulate any method that takes
two objects as parameters and returns an int.
Enterprise Library –Microsoft
Microsoft Enterprise Library is a collection of reusable application blocks designed to assist software developers with common enterprise development challenges.
 This release includes:
*      Caching Application Block
*      Cryptography Application Block
*      Data Access Application Block
*      Exception Handling Application Block
*      Logging Application Block
*      Policy Injection Application Block
*      Security Application Block
*      Validation Application Block
*      Unity Application Block.

The disadvantages of AJAX are:
  • Search engines would not be able to index an AJAX application.
  • The server information cannot be accessed within AJAX.
  • AJAX is not well integrated with any browser.
  • ActiveX requests are enabled only in IE 5 and IE6
  • Data of all requests is URL-encoded which increases the size of the request

SQL SERVER:

Constraints are used to limit the type of data that can go into a table.
Ø  Not Null
Ø  Unique
Ø  Primary Key
Ø  Foreign Key
Ø  Check
Ø  Default


Sql Not Null Constraint
The NOT NULL constraint enforces a column to NOT accept NULL values.
The NOT NULL constraint enforces a field to always contain a value. This means that you cannot insert a new record, or update a record without adding a value to this field.
Sql Unique Constraint
The UNIQUE constraint uniquely identifies each record in a database table.
The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns.
A PRIMARY KEY constraint automatically has a UNIQUE constraint defined on it.
Note that you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table
Sql Primary Key
The PRIMARY KEY constraint uniquely identifies each record in a database table.
Primary keys must contain unique values.
A primary key column cannot contain NULL values.
Each table should have a primary key, and each table can have only ONE primary key.
CREATE TABLE Persons
(
P_Id int NOT NULL PRIMARY KEY,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
ALTER TABLE Persons
DROP CONSTRAINT pk_PersonID
Sql foreign key
A FOREIGN KEY in one table points to a PRIMARY KEY in another table.
CREATE TABLE Orders
(
O_Id int NOT NULL PRIMARY KEY,
OrderNo int NOT NULL,
P_Id int FOREIGN KEY REFERENCES Persons(P_Id)
)

Sql Check Constraint
The CHECK constraint is used to limit the value range that can be placed in a column.
If you define a CHECK constraint on a single column it allows only certain values for this column.
If you define a CHECK constraint on a table it can limit the values in certain columns based on values in other columns in the row.
CREATE TABLE Persons
(
P_Id int NOT NULL CHECK (P_Id>0),
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
Sql Default Constriant

Ø  The DEFAULT constraint is used to insert a default value into a column.
Ø  The default value will be added to all new records, if no other value is specified.
Create Table _Orders
{
 O_Id int Not Null Primary Key,
O_name nvarchar(50) notnull,
O_Date Date Default GetDate()
}


Boxing and Un-Boxing

Boxing: means converting value-type to reference-type.
Eg:
int I = 20;
string s = I.ToSting();
UnBoxing: means converting reference-type to value-type.
Eg:
int I = 20;
string s = I.ToString(); //Box the int
int J = Convert.ToInt32(s); //UnBox it back to an int.
Note: Performance Overheads due to boxing and unboxing as the boxing makes a copy of 
value type from stack and place it inside an object of type System.Object in the heap.
What are Sealed Classes in C#?
The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if 
a sealed class is specified as the base class of another class. (A sealed class cannot also be 
an abstract class)

Polymorphism

Polymorphism means same operation may behave differently on different classes.
Eg:
Method Overloading is an example of Compile Time Polymorphism.
Method Overriding is an example of Run Time Polymorphism


Introduction
Web Farms and Web Garden are very common terminology for any production deployment. Though these terms looks same but the things are totally different. Many beginners very confused with these two terms. Here I am giving the basic difference between the Web Farm and Web Garden.
Web Farm
After developing our asp.net web application we host it on IIS Server.  Now one standalone server is sufficient to process ASP.NET Request and response for a small web sites but when the site comes for big organization where there an millions of daily user hits then we need to host the sites on multiple Server. This is called web farms. Where single site hosted on multiple IIS Server and they are  running behind the Load Balancer.
Fig : General Web Farm Architecture
This is the most common scenarios for any web based production environment. Where Client will hit an Virtual IP ( vIP) . Which is the IP address of Load Balancer. When Load balancer received the request based on the server load it will redirect the request to particular Server.
Web Garden
All IIS Request process by worker process ( w3wp.exe). By default each and every application pool contain single worker process. But An application pool with multiple worker process is called Web Garden.   Many worker processes with same Application Pool can sometimes provide better throughput performance and application response time. And Each Worker Process Should have there own Thread and Own Memory space.
There are some Certain Restriction to use Web Garden with your web application. If we use Session Mode to "in proc", our application will not work correctly because session will be handled by different Worker Process. For Avoid this Type of problem we should have to use Session Mode "out proc" and we can use "Session State Server" or "SQL-Server Session State".
How To Configure Web Garden?
Right Click on Application Pool > Properties > GoTo Performance Tab
In bottom Group Section  Increase the Worker Process Count.


select * into EmpTemp from Emp2( to insert one table data into another table)
insert into EmpTemp select * from Emp2(insert the data from one table to another table)

Followers