Tuesday, May 22, 2007

ASP.NET

ASP.NET is the latest version of Microsoft's Active Server Pages technology (ASP).

What you should already know
Before you continue you should have a basic understanding of the following:
· WWW, HTML and the basics of building Web pages
· Scripting languages like JavaScript or VBScript
· The basics of server side scripting

What is ASP?
ASP is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server.
· ASP is a Microsoft Technology
· ASP stands for Active Server Pages
· ASP is a program that runs inside IIS
· IIS stands for Internet Information Services
· IIS comes as a free component with Windows 2000
· IIS is also a part of the Windows NT 4.0 Option Pack
· The Option Pack can be downloaded from Microsoft
· PWS is a smaller - but fully functional - version of IIS
· PWS can be found on your Windows 95/98 CD

What is an ASP File?
· An ASP file is just the same as an HTML file
· An ASP file can contain text, HTML, XML, and scripts
· Scripts in an ASP file are executed on the server
· An ASP file has the file extension ".asp"

How Does it Work?
· When a browser requests an HTML file, the server returns the file
· When a browser requests an ASP file, IIS passes the request to the ASP engine on the server
· The ASP engine reads the file, line by line, and executes the scripts in the file
· Finally, the ASP file is returned to the browser as plain HTML

Before you study ASP .NET, it would help to have a basic understanding of Microsoft's ASP technology.

What is ASP+?
· ASP+ is the same as ASP.NET.
· ASP+ is just an early name used by Microsoft when they developed ASP.NET.

What is ASP.NET?
· ASP 3.0 is the latest version of ASP, but there will never be an ASP 4.0 version.
· ASP.NET is the next generation ASP, but it's not an upgraded version of ASP. ASP.NET is an entirely new paradigm for server-side ASP scripting.
· ASP.NET is a part of the .NET Framework. Microsoft spent three years rewriting ASP.NET from the ground up, and ASP.NET is not fully backward compatible with ASP 3.0.

.NET Framework
The .NET Framework is the infrastructure for the Microsoft .NET platform.
The .NET Framework is an environment for building, deploying, and running Web applications and Web Services.
The .NET Framework contains a common language runtime and common class libraries - like ADO.NET, ASP.NET and Windows Forms - to provide advanced standard services that can be integrated into a variety of computer systems.
The .NET Framework provides a feature-rich application environment, simplified development and easy integration between a number of different development languages.
The .NET Framework is language neutral. Currently it supports C++, C#, Visual Basic, and JScript (Microsoft's version of JavaScript).
Microsoft's Visual Studio.NET is a common development environment for the .NET Framework.


Differences between ASP and ASP .NET
ASP .NET has better language support, a large set of new controls and XML based components, and better user authentication.
ASP .NET provides increased performance by running compiled code.
ASP .NET code is not fully backward compatible with ASP.

New in ASP .NET
· Better language support
· Programmable controls
· Event-driven programming
· XML-based components
· User authentication, with accounts and roles
· Higher scalability
· Increased performance - Compiled code
· Easier configuration and deployment
· Not fully ASP compatible

Language Support
ASP .NET uses the new ADO .NET.
ASP .NET supports full Visual Basic, not VBScript.
ASP .NET supports C# (C sharp) and C++.
ASP .NET supports JScript as before.

ASP .NET Controls
ASP .NET contains a large set of HTML controls. Almost all HTML elements on a page can be defined as ASP .NET control objects that can be controlled by scripts.
ASP .NET also contains a new set of object oriented input controls, like programmable list boxes and validation controls.
A new data grid control supports sorting, data paging, and everything you expect from a dataset control.

Event Aware Controls
All ASP .NET objects on a Web page can expose events that can be processed by ASP .NET code.
Load, Click and Change events handled by code makes coding much simpler and much better organized.

ASP .NET Components
ASP .NET components are heavily based on XML. Like the new AD Rotator, that uses XML to store advertisement information and configuration.

User Authentication
ASP .NET supports forms-based user authentication, including cookie management and automatic redirecting of unauthorized logins.
(You can still do your custom login page and custom user checking).

User Accounts and Roles
ASP .NET allows for user accounts and roles, to give each user (with a given role) access to different server code and executables.

High Scalability
Much has been done with ASP .NET to provide greater scalability.
Server to server communication has been greatly enhanced, making it possible to scale an application over several servers. One example of this is the ability to run XML parsers, XSL transformations and even resource hungry session objects on other servers.

Compiled Code
The first request for an ASP .NET page on the server will compile the ASP .NET code and keep a cached copy in memory. The result of this is greatly increased performance.

Easy Configuration
Configuration of ASP .NET is done with plain text files.
Configuration files can be uploaded or changed while the application is running. No need to restart the server. No more metabase or registry puzzle.

Easy Deployment
No more server restart to deploy or replace compiled code. ASP .NET simply redirects all new requests to the new code.

Compatibility
ASP .NET is not fully compatible with earlier versions of ASP, so most of the old ASP code will need some changes to run under ASP .NET.
To overcome this problem, ASP .NET uses a new file extension ".aspx". This will make ASP .NET applications able to run side by side with standard ASP applications on the same server.


Installing ASP.NET
ASP.NET is easy to install. Just follow the instructions below.

What You Need
A Windows Computer
ASP.NET is a Microsoft technology. To run ASP.NET you need a computer capable of running Windows.

Windows 2000 or XP
If you are serious about developing ASP.NET applications you should install Windows 2000 Professional or Windows XP Professional.
In both cases, make sure you install the Internet Information Services (IIS) from the Add/Remove Windows components dialog.

Service Packs and Updates
Before ASP.NET can be installed on your computer, it is necessary to have all relevant service packs and security updates installed.
The easiest way to do this is to activate your Windows Internet Update. When you access the Windows Update page, you will be instructed to install the latest service packs and all critical security updates. For Windows 2000, make sure you install Service Pack 2. I will also recommend that you install Internet Explorer 6.
Read the note about connection speed and download time at the bottom of this page.

Remove Your Beta Version
If you have a Beta version of ASP.NET installed, we recommend that you completely uninstall it. Or even better: start with a fresh Windows 2000 or XP installation.
Install .NET
From your Windows Update you can now select to install the Microsoft .NET Framework.
After download, the .NET framework will install itself on your computer - there are no options to select for installation.
You should now be ready to develop your first ASP.NET application!

The .NET Software Development Kit
If you have the necessary bandwidth to download over 130 MB, you might consider downloading the full Microsoft .NET Software Development Kit (SDK).
We fully recommend getting the SDK for learning more about .NET and for the documentation, samples, and tools included.

Connection Speed and Download Time
If you have a slow Internet connection, you might have problems downloading large files like the service packs, the SDK and the latest version of Internet Explorer.
If download speed is a problem, our best suggestion is to get the latest files from someone else, from a colleague, from a friend, or from one of the CDs that comes with many popular computer magazines. Look for Windows 2000 Service Pack 2, Internet Explorer 6, and the Microsoft .NET Framework.

Monday, May 21, 2007

ADO.NET

Advantage of ADO.Net?
ADO.NET Does Not Depend On Continuously Live Connections
Database Interactions Are Performed Using Data Commands
Data Can Be Cached in Datasets
Datasets Are Independent of Data Sources
Data Is Persisted as XML
Schemas Define Data Structures

How would u connect to database using .NET?
SqlConnection nwindConn = new SqlConnection("Data Source=localhost; Integrated Security=SSPI;" + "Initial Catalog=northwind");nwindConn.Open();

What are relation objects in dataset and how & where to use them?
In a DataSet that contains multiple DataTable objects, you can use DataRelation objects to relate one table to another, to navigate through the tables, and to return child or parent rows from a related table. Adding a DataRelation to a DataSet adds, by default, a UniqueConstraint to the parent table and a ForeignKeyConstraint to the child table.
The following code example creates a DataRelation using two DataTable objects in a DataSet. Each DataTable contains a column named CustID, which serves as a link between the two DataTable objects. The example adds a single DataRelation to the Relations collection of the DataSet. The first argument in the example specifies the name of the DataRelation being created. The second argument sets the parent DataColumn and the third argument sets the child DataColumn
.custDS.Relations.Add("CustOrders",
custDS.Tables["Customers"].Columns["CustID"],
custDS.Tables["Orders"].Columns["CustID"]);
OR
private void CreateRelation()
{
// Get the DataColumn objects from two DataTable objects in a DataSet
.DataColumn parentCol;
DataColumn childCol;
// Code to get the DataSet not shown here
.parentCol = DataSet1.Tables["Customers"].Columns["CustID"];childCol = DataSet1.Tables["Orders"].Columns["CustID"];
// Create DataRelation
.DataRelation relCustOrder;
relCustOrder = new DataRelation("CustomersOrders", parentCol, childCol);
// Add the relation to the DataSet
.DataSet1.Relations.Add(relCustOrder);}

Difference between OLEDB Provider and SqlClient?
SQLClient .NET classes are highly optimized for the .net / sqlserver combination and achieve optimal results. The SqlClient data provider is fast. It's faster than the Oracle provider, and faster than accessing database via the OleDb layer. It's faster because it accesses the native library (which automatically gives you better performance), and it was written with lots of help from the SQL Server team.

What are the different namespaces used in the project to connect the database? What data providers available in .net to connect to database?
· System.Data.OleDb – classes that make up the .NET Framework Data Provider for OLE DB-compatible data sources. These classes allow you to connect to an OLE DB data source, execute commands against the source, and read the results.
· System.Data.SqlClient – classes that make up the .NET Framework Data Provider for SQL Server, which allows you to connect to SQL Server 7.0, execute commands, and read results. The System.Data.SqlClient namespace is similar to the System.Data.OleDb namespace, but is optimized for access to SQL Server 7.0 and later.
· System.Data.Odbc - classes that make up the .NET Framework Data Provider for ODBC. These classes allow you to access ODBC data source in the managed space.
· System.Data.OracleClient - classes that make up the .NET Framework Data Provider for Oracle. These classes allow you to access an Oracle data source in the managed space.

Difference between DataReader and DataAdapter / DataSet and DataAdapter?
You can use the ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. Using the DataReader can increase application performance and reduce system overhead because only one row at a time is ever in memory.
After creating an instance of the Command object, you create a DataReader by calling Command.ExecuteReader to retrieve rows from a data source, as shown in the following example
.SqlDataReader myReader = myCommand.ExecuteReader();
You use the Read method of the DataReader object to obtain a row from the results of the query.
while (myReader.Read())
Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1));
myReader.Close();
The DataSet is a memory-resident representation of data that provides a consistent relational programming model regardless of the data source. It can be used with multiple and differing data sources, used with XML data, or used to manage data local to the application. The DataSet represents a complete set of data including related tables, constraints, and relationships among the tables. The methods and objects in a DataSet are consistent with those in the relational database model. The DataSet can also persist and reload its contents as XML and its schema as XML Schema definition language (XSD) schema.
The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet. If you are connecting to a Microsoft SQL Server database, you can increase overall performance by using the SqlDataAdapter along with its associated SqlCommand and SqlConnection. For other OLE DB-supported databases, use the DataAdapter with its associated OleDbCommand and OleDbConnection objects.

Which method do you invoke on the DataAdapter control to load your generated dataset with data?
Fill()

Explain different methods and Properties of DataReader which you have used in your project?Read
GetString
GetInt32
while (myReader.Read())
Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1));
myReader.Close();

What happens when we issue Dataset.ReadXml command?
Reads XML schema and data into the DataSet.

In how many ways we can retrieve table records count? How to find the count of records in a dataset?
foreach(DataTable thisTable in myDataSet.Tables){
// For each row, print the values of each column.
foreach(DataRow myRow in thisTable.Rows){

How to check if a datareader is closed or opened?
IsClosed()

What happens when u try to update data in a dataset in .NET while the record is already deleted in SQL SERVER as backend?
OR What is concurrency? How will you avoid concurrency when dealing with dataset? (One user deleted one row after that another user through his dataset was trying to update same row. What will happen? How will you avoid the problem?)**

How do you merge 2 datasets into the third dataset in a simple manner? OR If you are executing these statements in commandObject. "Select * from Table1;Select * from Table2” how you will deal result set?**

How do you sort a dataset?**

If a dataset contains 100 rows, how to fetch rows between 5 and 15 only?**

Differences between dataset.clone and dataset.copy?
Clone - Copies the structure of the DataSet, including all DataTable schemas, relations, and constraints. Does not copy any data.
Copy - Copies both the structure and data for this DataSet.

What is the use of parameter object?**

How to generate XML from a dataset and vice versa?**

What is method to get XML and schema from Dataset?
getXML () and get Schema ()

How do u implement locking concept for dataset?**

C# Language Features

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)

What is Polymorphism? How does VB.NET/C# achieve polymorphism?**
class Token
{
public string Display()
{
//Implementation goes here
return "base";
}
}
class IdentifierToken:Token
{
public new string Display() //What is the use of new keyword
{
//Implementation goes here
return "derive";
}
}
static void Method(Token t)
{
Console.Write(t.Display());
}
public static void Main()
{
IdentifierToken Variable=new IdentifierToken();
Method(Variable); //Which Class Method is called here
Console.ReadLine();
}
For the above code What is the "new" keyword and Which Class Method is called here
It will call base class Display method

class Token
{
public virtual string Display()
{
//Implementation goes here
return "base";
}
}
class IdentifierToken:Token
{
public override string Display() //What is the use of new keyword
{
//Implementation goes here
return "derive";
}
}
static void Method(Token t)
{
Console.Write(t.Display());
}
public static void Main()
{
IdentifierToken Variable=new IdentifierToken();
Method(Variable); //Which Class Method is called here
Console.ReadLine();
}
Derive

In which Scenario you will go for Interface or Abstract Class?
· Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes. Even though class inheritance allows your classes to inherit implementation from a base class, it also forces you to make most of your design decisions when the class is first published.
· Abstract classes are useful when creating components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. They also version well, because if additional functionality is needed in derived classes, it can be added to the base class without breaking code.



Interfaces vs. Abstract Classes
Feature --> Interface --> Abstract class
Multiple inheritance
1. A class may implement several interfaces.
2. A class may extend only one abstract class.

Default implementation
1. An interface cannot provide any code at all, much less default code.
2. An abstract class can provide complete code, default code, and/or just stubs that have to be overridden.

Constants
1. Static final constants only, can use them without qualification in classes that implement the interface. On the other paw, these unqualified names pollute the namespace. You can use them and it is not obvious where they are coming from since the qualification is optional.
2. Both instance and static constants are possible. Both static and instance intialiser code are also possible to compute the constants.

Third party convenience
1. An interface implementation may be added to any existing third party class.
2. A third party class must be rewritten to extend only from the abstract class.

is-a vs -able or can-do
1. Interfaces are often used to describe the peripheral abilities of a class, not its central identity, e.g. an Automobile class might implement the Recyclable interface, which could apply to many otherwise totally unrelated objects.
2. An abstract class defines the core identity of its descendants. If you defined a Dog abstract class then Damamation descendants are Dogs, they are not merely dogable. Implemented interfaces enumerate the general things a class can do, not the things a class is.

Plug-in
1. You can write a new replacement module for an interface that contains not one stick of code in common with the existing implementations. When you implement the interface, you start from scratch without any default implementation. You have to obtain your tools from other classes; nothing comes with the interface other than a few constants. This gives you freedom to implement a radically different internal design.
2. You must use the abstract class as-is for the code base, with all its attendant baggage, good or bad. The abstract class author has imposed structure on you. Depending on the cleverness of the author of the abstract class, this may be good or bad. Another issue that's important is what I call "heterogeneous vs. homogeneous." If implementors/subclasses are homogeneous, tend towards an abstract base class. If they are heterogeneous, use an interface. (Now all I have to do is come up with a good definition of hetero/homogeneous in this context.) If the various objects are all of-a-kind, and share a common state and behavior, then tend towards a common base class. If all they share is a set of method signatures, then tend towards an interface.

Homogeneity
1. If all the various implementations share is the method signatures, then an interface works best.
2. If the various implementations are all of a kind and share a common status and behavior, usually an abstract class works best.

Maintenance
1. If your client code talks only in terms of an interface, you can easily change the concrete implementation behind it, using a factory method.
2. Just like an interface, if your client code talks only in terms of an abstract class, you can easily change the concrete implementation behind it, using a factory method.

Speed
1. Slow, requires extra indirection to find the corresponding method in the actual class. Modern JVMs are discovering ways to reduce this speed penalty.
2. Fast

Terseness
1. The constant declarations in an interface are all presumed public static final, so you may leave that part out. You can't call any methods to compute the initial values of your constants. You need not declare individual methods of an interface abstract. They are all presumed so.
2. You can put shared code into an abstract class, where you cannot into an interface. If interfaces want to share code, you will have to write other bubblegum to arrange that. You may use methods to compute the initial values of your constants and variables, both instance and static. You must declare all the individual methods of an abstract class abstract.

Adding functionality
1. If you add a new method to an interface, you must track down all implementations of that interface in the universe and provide them with a concrete implementation of that method.
2. If you add a new method to an abstract class, you have the option of providing a default implementation of it. Then all existing code will continue to work without change.

Write one code example for compile time binding and one for run time binding? What is early/late binding?
An object is early bound when it is assigned to a variable declared to be of a specific object type. Early bound objects allow the compiler to allocate memory and perform other optimizations before an application executes.' Create a variable to hold a new object.Dim FS As FileStream' Assign a new object to the variable.FS = New FileStream("C:\tmp.txt", FileMode.Open)By contrast, an object is late bound when it is assigned to a variable declared to be of type Object. Objects of this type can hold references to any object, but lack many of the advantages of early-bound objects.Dim xlApp As ObjectxlApp = CreateObject("Excel.Application")

Can you explain what inheritance is and an example of when you might use it?

How can you write a class to restrict that only one object of this class can be created (Singleton class)?

Constructor/Destructor

Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?
(Class constructor method is also known as type constructor or type initializer)Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention.A static constructor is used to initialize a class. It is called automatically to initialize the class before the first instance is created or any static members are referenced.

What is Private Constructor? and it’s use? Can you create instance of a class which has Private Constructor?
When a class declares only private instance constructors, it is not possible for classes outside the program to derive from the class or to directly create instances of it. (Except Nested classes)Make a constructor private if:- You want it to be available only to the class itself. For example, you might have a special constructor used only in the implementation of your class' Clone method.- You do not want instances of your component to be created. For example, you may have a class containing nothing but Shared utility functions, and no instance data. Creating instances of the class would waste memory.

I have 3 overloaded constructors in my class. In order to avoid making instance of the class do I need to make all constructors to private?(yes)

Overloaded constructor will call default constructor internally?(no)

What are virtual destructors?

Destructor and finalize
Generally in C++ the destructor is called when objects gets destroyed. And one can explicitly call the destructors in C++. And also the objects are destroyed in reverse order that they are created in. So in C++ you have control over the destructors.In C# you can never call them, the reason is one cannot destroy an object. So who has the control over the destructor (in C#)? it's the .Net frameworks Garbage Collector (GC). GC destroys the objects only when necessary. Some situations of necessity are memory is exhausted or user explicitly calls System.GC.Collect() method.Points to remember:
1. Destructors are invoked automatically, and cannot be invoked explicitly.
2. Destructors cannot be overloaded. Thus, a class can have, at most, one destructor.
3. Destructors are not inherited. Thus, a class has no destructors other than the one, which may be declared in it.
4. Destructors cannot be used with structs. They are only used with classes.
5. An instance becomes eligible for destruction when it is no longer possible for any code to use the instance.
6. Execution of the destructor for the instance may occur at any time after the instance becomes eligible for destruction.
7. When an instance is destructed, the destructors in its inheritance chain are called, in order, from most derived to least derived.http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconfinalizemethodscdestructors.asp

What is the difference between Finalize and Dispose (Garbage collection)
Class instances often encapsulate control over resources that are not managed by the runtime, such as window handles (HWND), database connections, and so on. Therefore, you should provide both an explicit and an implicit way to free those resources. Provide implicit control by implementing the protected Finalize Method on an object (destructor syntax in C# and the Managed Extensions for C++). The garbage collector calls this method at some point after there are no longer any valid references to the object.In some cases, you might want to provide programmers using an object with the ability to explicitly release these external resources before the garbage collector frees the object. If an external resource is scarce or expensive, better performance can be achieved if the programmer explicitly releases resources when they are no longer being used. To provide explicit control, implement the Dispose method provided by the IDisposable Interface. The consumer of the object should call this method when it is done using the object. Dispose can be called even if other references to the object are alive.Note that even when you provide explicit control by way of Dispose, you should provide implicit cleanup using the Finalize method. Finalize provides a backup to prevent resources from permanently leaking if the programmer fails to call Dispose.

What is close method? How its different from Finalize & Dispose?**

What is boxing & unboxing?

What is check/uncheck?

What is the use of base keyword? Tell me a practical example for base keyword’s usage?

What are the different .net tools which u used in projects?


try
{...}
catch
{...//exception occurred here. What'll happen?}
finally{..}
It will throw exception.

What will do to avoid prior case?try
{
try
{
...
}
catch
{
...
//exception occurred here.
}
finally
{
...
}
}
catch
{
...
}
finally
{
...
}
try
{
...
}
catch
{
...
}
finally
{
..
}

Will it go to finally block if there is no exception happened?
Yes. The finally block is useful for cleaning up any resources allocated in the try block. Control is always passed to the finally block regardless of how the try block exits.

Is goto statement supported in C#? How about Java?
Gotos are supported in C#to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality.

What’s different about switch statements in C#?
No fall-throughs allowed. Unlike the C++ switch statement, C# does not support an explicit fall through from one case label to another. If you want, you can use goto a switch-case, or goto default.
case 1:cost += 25;break;case 2:cost += 25;goto case 1;

Access Specifiers

What are the access-specifiers available in c#?
Private, Protected, Public, Internal, Protected Internal.

Explain about Protected and protected internal, “internal” access-specifier?
protected - Access is limited to the containing class or types derived from the containing class. internal - Access is limited to the current assembly.protected internal - Access is limited to the current assembly or types derived from the containing class.

OOPS

What are the OOPS concepts?
· Encapsulation: It is the mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse. In short it isolates a particular code and data from all other codes and data. A well-defined interface controls the access to that particular code and data.
· Inheritance: It is the process by which one object acquires the properties of another object. This supports the hierarchical classification. Without the use of hierarchies, each object would need to define all its characteristics explicitly. However, by use of inheritance, an object need only define those qualities that make it unique within its class. It can inherit its general attributes from its parent. A new sub-class inherits all of the attributes of all of its ancestors.
· Polymorphism: It is a feature that allows one interface to be used for general class of actions. The specific action is determined by the exact nature of the situation. In general polymorphism means "one interface, multiple methods", This means that it is possible to design a generic interface to a group of related activities. This helps reduce complexity by allowing the same interface to be used to specify a general class of action. It is the compiler's job to select the specific action (that is, method) as it applies to each situation.

What is the difference between a Struct and a Class?
· The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects, you will allocate additional memory for referencing each object. In this case, the struct is less expensive.
· When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized.
· It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.
· It is an error to initialize an instance field in a struct.
· There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.
· A struct is a value type, while a class is a reference type.

Value type & reference types difference?
Example from .NET. Integer & struct are value types or reference types in .NET?Most programming languages provide built-in data types, such as integers and floating-point numbers, that are copied when they are passed as arguments (that is, they are passed by value). In the .NET Framework, these are called value types. The runtime supports two kinds of value types:
· Built-in value types The .NET Framework defines built-in value types, such as System.Int32 and System.Boolean, which correspond and are identical to primitive data types used by programming languages.
· User-defined value types Your language will provide ways to define your own value types, which derive from System.ValueType. If you want to define a type representing a value that is small, such as a complex number (using two floating-point numbers), you might choose to define it as a value type because you can pass the value type efficiently by value. If the type you are defining would be more efficiently passed by reference, you should define it as a class instead.
Variables of reference types, referred to as objects, store references to the actual data. This following are the reference types:
· class
· interface
· delegate
This following are the built-in reference types:
· object
· string

What is Inheritance, Multiple Inheritance, Shared and Repeatable Inheritance?**

What is Method overloading?
Method overloading occurs when a class contains two methods with the same name, but different signatures.

What is Method Overriding? How to override a function in C#?
Use the override modifier to modify a method, a property, an indexer, or an event. An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.

Can we call a base class method without creating instance?
· Its possible If its a static method.
· Its possible by inheriting from that class also.
· Its possible from derived classes using base keyword.

You have one base class virtual function how will call that function from derived class?
class a
{
public virtual int m()
{
return 1;
}
}
class b:a
{
public int j()
{
return m();
}
}

In which cases you use override and new base?
Use the new modifier to explicitly hide a member inherited from a base class. To hide an inherited member, declare it in the derived class using the same name, and modify it with the new modifier.

COM

Interop Services?
The common language runtime provides two mechanisms for interoperating with unmanaged code:
· Platform invoke, which enables managed code to call functions exported from an unmanaged library.
· COM interop, which enables managed code to interact with COM objects through interfaces.
· Both platform invoke and COM interop use interop marshaling to accurately move method arguments between caller and callee and back, if required.

How does u handle this COM components developed in other programming languages in .NET?
What is RCW (Runtime Callable Wrappers)?
The common language runtime exposes COM objects through a proxy called the runtime callable wrapper (RCW). Although the RCW appears to be an ordinary object to .NET clients, its primary function is to marshal calls between a .NET client and a COM object.

What is CCW (COM Callable Wrapper)
A proxy object generated by the common language runtime so that existing COM applications can use managed classes, including .NET Framework classes, transparently.

How CCW and RCW is working?**

How will you register com+ services?
The .NET Framework SDK provides the .NET Framework Services Installation Tool (Regsvcs.exe - a command-line tool) to manually register an assembly containing serviced components. You can also access these registration features programmatically with the System.EnterpriseServicesRegistrationHelper class by creating an instance of class RegistrationHelper and using the method InstallAssembly.

What is use of ContextUtil class?
ContextUtil is the preferred class to use for obtaining COM+ context information.

What is the new three features of COM+ services, which are not there in COM (MTS)?**

Is the COM architecture same as .Net architecture? What is the difference between them?**

Can we copy a COM dll to GAC folder?**

What is Pinvoke?
Platform invoke is a service that enables managed code to call unmanaged functions implemented in dynamic-link libraries (DLLs), such as those in the Win32 API. It locates and invokes an exported function and marshals its arguments (integers, strings, arrays, structures, and so on) across the interoperation boundary as needed.

Is it true that COM objects no longer need to be registered on the server?
Answer: Yes and No. Legacy COM objects still need to be registered on the server before they can be used. COM developed using the new .NET Framework will not need to be registered. Developers will be able to auto-register these objects just by placing them in the 'bin' folder of the application.
Can .NET Framework components use the features of Component Services?Answer: Yes, you can use the features and functions of Component Services from a .NET Framework component. http://msdn.microsoft.com/library/techart/Pahlcompserv.htm