Interview Questions

(ratigs etc ) http://www.labnol.org/internet/blogging/useful-blog-addons-for-blogger-wordpress/4171/

http://challagullainfo.blogspot.com/
(google gadgets)http://www.quickonlinetips.com/archives/2008/03/10-best-google-gadgets-for-blogs/

http://interview.fyicenter.com/1710_.NET_ASP.NET_In_which_event_are_the_controls_fully_loaded.html

koyrala dotnet interview ques



http://www.interviewmantra.net/2009/11/10-number-pattern-programs.html#ques3


Import Gmail Contacts into ASP.NET GridView
http://www.c-sharpcorner.com/UploadFile/BangaruBabu/701/

* Alexa for back liks ......

* Google analytics  :for clicks and ranks

a.Equals(b)

a.Equals(b) handles NULL values

a==b does not handle NULL values.It will throw NULL Reference Exception.

a=b is used for assigning the values (rather then comparison) and a==b is for comparison.

Or
a == b is used to compare the references of two objects
a.Equals(b) is used to compare two objects
Or

a equals b -> copies contents of b to a
a == b -> checks if a is equal to b 

How does delegate differ from an event?

This is one of the important and most asked .NET interview questions. Delegate is basically an abstract strong pointer to a function or method while events are higher level of encapsulation over delegates.

Events are used by delegates internally.

Main differing reasons are as follows:-

• Actually, events use delegates in bottom. But they add an extra layer on the
delegates, thus forming the publisher and subscriber model.

• As delegates are function to pointers, they can move across any clients. So
any of the clients can add or remove events, which can be confusing. But events
give the extra protection / encapsulation by adding the layer and making it a
publisher and subscriber model.

Think that one of your clients doing this

c.XyzCallback = null
This will reset all your delegates to nothing and you have to keep searchingwhere the error is.
Smart navigation
Smart navigation makes web application a real fantastic and pretty look that it feels like it is a window application. Now the questions comes in our mind how its makes web application to window application because one of the drawback of web application is the http architecture means when client send some request to server data is post back and data when come back full redrawing of page it takes really lot of time not only this but also goes top of screen and does not maintain focus on same control on before post back.

But in window application user have ability to change a part or required part to be effected with out change in full page. The smart navigation helps webapplication to redrawing a full page after post back.

But there is some condition that is always there, the internet explorer must be greater then or equal to version 5. There are many situations where smart navigation do really well enough. We can disable/enable the smart navigation as well. We can use multiple browsers because smart navigation detects it enable on supported browser. There are many more features that smart navigation has:

• Restrict on screen flash.

• Scroll position remains as it is.

• Focus remains as it is.

• History of last page also maintains.

Smart navigation really plays well where lot of post back is to be taken. And another feature that makes it so popular is coder not to code too much for that. This is controlled by the web.config file and a little thing in page directive.


Assemblies
Assemblies are similar to dll files. Both has the reusable pieces of code in the form of classes/ functions. Dll needs to be registered but assemblies have its own metadata.
Or
Assembly is a single deployable unit that contains information about the implementation of classes, structures and interfaces. it also stores the information about itself calledmetadata and includes name and verison of the assembly, security information, information about the dependencies and the list of files that constitute the assembly.
Assembly also contains namespaces. In the .Net Framework, applications are deployed in the form of assemblies.
Or
An assembly is a single deployable unit that contains all the information about the implementation of :
- classes
- structures and
- interfaces


How do you turn off cookies for one page in your site?
Use the Cookie.Discard Property which Gets or sets the discard flag set by the server. When true, thisproperty instructs the client application not to save the Cookie on the user?s hard disk when a session ends.

Or

it can be turned off by mentioning cookie state= false in web.config file


You can mentioning cookie state= false in web.config file.This will turn off session cookie.

Why is catch(Exception) almost always a bad idea?
Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.

Catch(Exception) is used when you are not sure that which exception will be thrown by the code. This syntax will handle all system define exception. But bad side of using this syntax is that it slowdowns the execution speed as CLR have to check each possible exception.


Explain the differences between Server-side and Client-side code?
Server side is the code that resides at web server.
For every client request code is executed at server side and result is send to the client in simple HTML format.
Performance is lower than client side code due to server round trips.
Client cannot see the business logic though it is stored on server.

Client Side Code
-------------------
Client side code is reside at client's browser itself. It is executed at client side only. User can easily see the code by View - > Source option.
It is generally used in validation form like text field is empty or not, email address validation etc. It is faster than server side code.  
What is a Strong Name?  
A strong name consists of the assembly's identity ? its simple text name, version number, and culture information (if provided) ? plus a public key and a digital signature. It is generated from an assembly file (the file that contains the assembly manifest, which in turn contains the names and hashes of all the files that make
up the assembly), using the corresponding private key. Assemblies with the same strong name are expected to be identical.

Why use SQL?

Once you start running multiple web servers for the same web site, the default asp.net session state, InProc, is no longer useful, as you cannot guarantee that each page request goes to the same server. It becomes necessary to have a central state store that every web server accesses.
SQL Server offers you centralized storage of a session state in a Web farm. It also offers the transactional capabilities that provide reliability to most relational database systems. You can use SQL Server to save a session. This process is not as efficient as InProc and StateServer mode, because you must store the information in a different process or on a different server. However, this option may be more efficient than using the aspnet_state service, depending on the actual workload and the database configuration. Once you start saving session state to a SQL database it will also persist through web server restarts and reboots.


1.What is the difference between Copy and Clone Method?

Clone will copy the structure of a data where as
Copy will copy the complete structure as well as data.

2.Difference between abstract class and interface?


i.An abstract class may contain complete or incomplete methods. Interfaces can contain only the signature of a method but no body. Thus an abstract class can implement methods but an interface can not implement methods.

ii.An abstract class can contain fields, constructors, or destructors and implement properties. An interface can not contain fields, constructors, or destructors and it has only the property's signature but no implementation.

iii.An abstract class cannot support multiple inheritance, but an interface can support multiple inheritance. Thus a class may inherit several interfaces but only one abstract class.

iv.A class implementing an interface has to implement all the methods of the interface, but the same is not required in the case of an abstract Class.

v.Various access modifiers such as abstract, protected, internal, public, virtual, etc. are useful in abstract Classes but not in interfaces.

vi.Abstract classes are faster than interfaces.

a)A class may inherit only one abstract class, but may implement multiple number of Interfaces. Say a class named Car needs to inherit some basic features of a vehicle, it may inherit from an Abstract class named Vehicle. A car may be of any kind, it may be a vintage car, a sedan, a coupe, or a racing car. For these kind of requirements, say a car needs to have only two seats (means it is a coupe), then the class Car needs to implement a member field from an interface, that we make, say ICoupe.

b)Members of an abstract class may have any access modifier, but members of an interface are public by default, and cant have any other access modifier.

c)Abstract class methods may OR may not have an implementation, while methods in an Interface only have a definition, no implementation.

3.Understanding Constructors in C#


Constructors are used for initializing the members of a class whenever an object is created with the default values for initialization.
If a class is not defined with the constructor then the CLR (Common Language Runtime) will provide an implicit constructor which is called as Default Constructor.

A class can have any number of constructors provided they vary with the number of arguments that are passed, which is they should have different signatures.
- Constructors do not return a value.
- Constructors can be overloaded.
- If a class is defined with static and Non-static constructors then the privilege will be given to the Non-static constructors.

The following are the access modifiers for constructors,
Public: A constructor that is defined as public will be called whenever a class is instantiated.
Protected: A constructor is defined as protected in such cases where the base class will initialize on its own whenever derived types of it are created.
Private: A constructor is defined as private in such cases whenever a class which contains only static members has to be accessed will avoid the creation of the object for the class.
Internal: An internal constructor can be used to limit concrete implementations of the abstract class to the assembly defining the class. A class containing an internal constructor cannot be instantiated outside of the assembly.
External: When a constructor is declared using an extern modifier, the constructor is said to be an external constructor.
Types of Constructors
i) Static: Used for initializing only the static members of the class. These will be invoked for the very first time the class is being loaded on the memory. They cannot accept any arguments. Static Constructors cannot have any access modifiers.
Syntax ----
Static ClassName()
{
//Initialization statements;
}
ii) Non-Static: are used for initializing the Non-Static and Static members of a class. These will be invoked everytime a new object is defined for a class.
Syntax ---
Public ClassName([argsInfo])
{
//Initialization statements;
}
Example :
Using System;
Class SampleConstructor
{
public static int s;
public int ns;
static SampleConstructor()
{
s = 10;
//ns = 20; --- Error cannot be assigned like this
}
public SampleConstructor()
{
ns=100;
s=200;
}
}
Class UseSampleConstructor
{
public static void Main()
{
SampleConstructor sc = new SampleConstructor();
Console.WriteLine(“{0},{1}”,sc.s, SampleConstructor.s, sc.ns);
} l
} l
Error (Cannot call like this)
If you observe in the above example the static variable `ns' cannot be assigned a value in the static Constructor as it is a Non-static member of the class and a static constructor cannot initialize a Non-Static member.
Also as you see in the above code the Non-static constructor initializing the values for both the static and Non-Static members of class, when we say `sc' we are creating an object for the class and using the object we do the call the methods, it is not valid to call a static member of class using the object of the class we have to call it through the method name/Constructor name through the member will be invoked.

5. What is the difference between constant and read-only?

A. When using the const keyword to set a constant variable, the value needs to be set at compile time. The const keyword may not be used with an object of reference type.

In case a reference type needs to be assigned a non-changeable value, it may be set as read-only.
Or
Readonly variable can be assigned at declaration or at run time which is must be in constructor. Readonly value can't be modified.

Constant variable must be assigned at the time of declaration only ,which is can't be modified.

Or
The readonly keyword differs from the const keyword. A const field can only be initialized at the declaration of the field. A readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used. Also, although a const field is a compile-time constant, the readonly field can be used for run-time constants, as in this line: public static readonly uint l1 = (uint)DateTime.Now.Ticks;
So what does that actually mean? Well, without getting into the boring low level details, I will try to explain.

When using const, the value has to be set before compiling, and can not be changed. Once you make your assembly, the value of the const is baked in there. If you want to change the value of the const, you must go back into your code, change the value, then recompile.
If another assembly (Assembly B) wants to use the const in the first assembly (Assembly A), the const is also baked in there as well. So, if you change the value of the const, not only will you have to rebuild your first Assembly (Assembly A), you will also have to build all other assemblies (Assembly B, C, D, …).
Unlike const, when using readonly, the value is set when the instance is created. This means that you can specify the value of the readonly in the constructor of your class.
Another difference between const and readonly, is that const are static by default, where with readonly, you must define it as static (if you want it to be).
As I mentioned above, when you change the value of a const, you must rebuild your assembly. So if the value can change, you should think about using readonly instead. To store the date for Thanksgiving (since it changes from year to year), readonly should probably be used, where as the date for New Years could be specified in a const. You could use const for things like the number of days in a week and months in a year. If you’re retrieving settings from a config file (such as urls or server addresses) and they won’t be changed after they are retrieved, then use readonly.
This is just a quick comparison between the two. If you know of anything that I have missed, or have any stories that you would like to share from personal experiences using either one, feel free to share.

5. INDEXER IN C#:

In c# introduce new concept is Indexer. This is very useful for some situation. Let as discuss something about Indexer.

• Indexer Concept is object act as an array.
• Indexer an object to be indexed in the same way as an array.
• Indexer modifier can be private, public, protected or internal.
• The return type can be any valid C# types.
• Indexers in C# must have at least one parameter. Else the compiler will generate a compilation error.
this [Parameter]
{
get
{
// Get codes goes here
}
set
{
// Set codes goes here
}
}

For Example:

using System;
using System.Collections.Generic;
using System.Text;

namespace Indexers
{
class ParentClass
{
private string[] range = new string[5];
public string this[int indexrange]
{
get
{
return range[indexrange];
}
set
{
range[indexrange] = value;
}
}
}

/* The Above Class just act as array declaration using this pointer */

class childclass
{
public static void Main()
{
ParentClass obj = new ParentClass();

/* The Above Class ParentClass create one object name is obj */

obj[0] = "ONE";
obj[1] = "TWO";
obj[2] = "THREE";
obj[3] = "FOUR ";
obj[4] = "FIVE";
Console.WriteLine("WELCOME TO C# CORNER HOME PAGE\n");
Console.WriteLine("\n");

Console.WriteLine("{0}\n,{1}\n,{2}\n,{3}\n,{4}\n", obj[0], obj[1], obj[2], obj[3], obj[4]);
Console.WriteLine("\n");
Console.WriteLine("ALS.Senthur Ganesh Ram Kumar\n");
Console.WriteLine("\n");
Console.ReadLine();
}
}
}



Indexer:
If we heard the word indexers or index, the name "Array" will come to our mind.
Arrays are accessed by using the index. In the same way in C# also, Indexer is used to access the class instances by means of index notation.

Syntax for Declaration:
public type this [type identifier]
Ex : public string this [int myIndex]

Declaring Indexer
public string this[int myCompanies]
{
get{
return mycompanies[index]
}
set{
}
}

6. Explain how to add controls dynamically to the form using C#.NET.

The following code can be called on some event like page load or onload of some image or even a user action like onclick
protected void add_button(Button button)
{
try
{
panel1.Controls.Add(button); // Add the control to the container on a page
}
catch (Exception ex)
{
label1.Text += ex.Message.ToString();
}
}

7. How to achieve polymorphism in C#.NET?

Polymorphism is when a class can be used as more than one type through inheritance. It can be used as its own type, any base types, or any interface type if it implements interfaces.
It can be achieved in the following ways:
Derived class inherits from a base class and it gains all the methods, fields, properties and events of the base class.
To completely take over a class member from a base class, the base class has to declare that member as virtual.

8. What are implementation inheritance and interface inheritance?

Implementation inheritance is achieved when a class is derived from another class in such a way that it inherits all its members.
Interface inheritance is when a class inherits only the signatures of the functions from another class.

9. How to add a ReadOnly property in C#.NET?

Properties can be made read-only by having only a get accessor in the implementation.
public class X
{
public X(int id)
{
x_id = id;
}
public int ID
{
get
{
return x_id;
}
}
}

10. How to prevent a class from being inherited in C#.NET?

The sealed modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class. A sealed class cannot also be an abstract class.

11. What is the difference between Debug.Write and Trace.Write? When should each be used?

Debug.Write: Debug Mode, Release Mode (used while debuging a project)
Trace.write: Release Mode (used in Released verion of Applications)

12. Explain the use of static members with example using C#.NET.

Static members are not associated with a particular instance of any class.
They need to be qualified with the class name to be called.
Since they are not associated with object instances, they do not have access to non-static members.
i.e.: "this" cannot be used, which represents the current object instance.

13. Explain the use of virtual, sealed, override, and abstract.

The virtual keyword enables a class to be overridden. If it has to be prevented from being overridden, then the sealed keyword needs to be used. If the keyword virtual is not used, members of the class can even then be overridden. However, its usage is advised for making the code meaningful.
The override keyword is used to override the virtual method in the base class. Abstract keyword is used to modify a class, method or property declaration. You cannot instantiate an abstract class or make calls to an abstract method directly.
An abstract virtual method means that the definition of the method needs to be given in the derived class.

14. What are generics in C#.NET?

Generic types to maximize code reuse, type safety, and performance.
They can be used to create collection classes.
Generic collection classes in the System.Collections.Generic namespace should be used instead of classes such as ArrayList in the System.Collections namespace.

15. What is C#.NET Generics?

The classes and the methods can treat the values of different types uniformly with the use if generics.
The usage of generics is advantageous as:
- They facilitate type safety
- They facilitate improved performance
- They facilitate reduced code
- They promote the usage of parameterized types
- The CLR compiles and stores information related to the generic types when they are instantiated. (The generic type instance refers to the location in memory of the reference type to which it is bound for all the instances of the generic type.)
Generics allow you to define type-safe data structures, without committing to actual data types. It allows writing less but more effective code. Generic provides flexibility and power but the developer needs to be responsible while using it.

16. What is an object pool in .NET?

An object pool is a container of objects that holds a list of other objects that are ready to be used.
It keeps track of:
- Objects that are currently in use
- The number of objects the pool holds
- Whether this number should be increased
The request for the creation of an object is served by allocating an object from the pool.
This reduces the overhead of creating and re-creating objects each time an object creation is required.

17. Why is an Object Pool required?

The request for the creation of an object is served by allocating an object from the pool.
This reduces the overhead of creating and re-creating objects each time an object creation is required.

18. What is the difference between Finalize() and Dispose()?

Dispose() is called by as an indication for an object to release any unmanaged resources it has held.
Finalize() is used for the same purpose as dispose however finalize doesn’t assure the garbage collection of an object.
Dispose() operates determinalistically due to which it is generally preferred.

19. Why it is bad to throw our own exceptions in try catch bock
If we know the point where an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.

20. What is a SqlCommandBuilder in ADO.NET?

SqlCommandBuilder class in ADO.NET provides the feature of reflecting the changes made to a DataSet or an instance of the SQL server data. When an instance of the SqlCommandBuilder class is created, it automatically generates Transact-SQL statements for the single table updates that occur. The object of the SqlCommandBuilder acts as a listener for RowUpdating events, whenever the DataAdapter property is set.

The SqlCommandBuilder object automatically generates the values contained within the SqlDataAdapter's InsertCommand, UpdateCommand and DeleteCommand properties based on the initial SelectCommand. The advantage here is that you will not need to write SqlCommand & SqlParameter Types explicitly.

Basically the command builder object builds these objects on the fly. The command builder object actually reads the metadata of the method called. After the builder object reads the underlying schema of the adapter's method, it autogenerates an underlying insert, update & delete command object. See code example below...
//Code below in C#...
DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection("strSomeConnectionString");
//Autogenerate Insert, Update & Delete commands
SqlDataAdapter da = new SqlDataAdapter("Select from t_Something", cn);
SqlCommandBuilder scb = new SqlCommand(da);

//Fill the dataset
da.Fill(ds,"t_Something");


21. Data Readers
A DataReader is a lightweight object that provides read-only, forward-only data in a very fast and efficient way. Using a DataReader is efficient than using a DataAdapter but it is limited. Data access with DataReader is
read-only, meaning, we cannot make any changes (update) to data and forward-only, which means we cannot go back to the previous record which was accessed. A DataReader requires the exclusive use of an active connection for the entire time it is in existence. We instantiate a DataReader by making a call to a Command object's ExecuteReader command. When the DataReader is first returned it is positioned before the first record of the result set. To make the first record available we need to call the Read method. If a record is available, the Read method moves the DataReader to next record and returns True. If a record is not available the Read method returns False. We use a While Loop to iterate through the records with the Read method.

View State

1. What is ViewState?

Web forms have very short lifetimes.In ASP.NET, the data that is entered in controls is encoded and stored in a hidden field. This encoded data is then sent with each request and restored to controls in Page_Init. The data in these controls is then available in the Page_Load event.The data that ASP.NET preserves between requests is called the Web form’s view state.

2. How do you enable or disable a ViewState for a control on the page
Every ASP.NET control has a property called EnableViewState. If EnableViewState is set to true ViewState is enabled for the control. If EnableViewState is set to false ViewState is disabled for the control.

3. How do you enable or disable a ViewState at the page level?

At the page level you can enable or disable ViewState using EnableViewState property of the page.

4. What is the name of the hidden form field in which ViewState of the page is saved?

__ViewState

5. What are the performance implications of ViewState?
ViewState is usually good to retain the state of the controls on the webform across postbacks. If you have a huge DataGrid with tons of data being loaded on every page load. It is a good idea to disable the ViewState of the DataGrid for the page to load faster. If the ViewState of a large DataGrid is not disabled, ViewState can easily get very large, on the order of tens of kilobytes. Not only does the __ViewState form field cause slower downloads, but, whenever the user posts back the Web page, the contents of this hidden form field must be posted back in the HTTP request, thereby lengthening the request time, as well.

6. When does ViewState restoration happens?

During the Page_Init event

7. What are the disadvantages of using ViewState?

1. On all page visits, during the save view state stage the Page class gathers the collective view state for all of the controls in its control hierarchy and serializes the state to a base-64 encoded string. (This is the string that is emitted in the hidden __ViewState form filed.) Similarly, on postbacks, the load view state stage needs to deserialize the persisted view state data, and update the pertinent controls in the control hierarchy.

2. The __ViewState hidden form field adds extra size to the Web page that the client must download. For some view state-heavy pages, this can be tens of kilobytes of data, which can require several extra seconds (or minutes!) for modem users to download. Also, when posting back, the __ViewState form field must be sent back to the Web server
in the HTTP POST headers, thereby increasing the postback request time.

8. Is ViewState encoded?

Yes, ViewState is base-64 encoded.

9. Can you encrypt ViewState of Page?

Yes, we can use the LosFormatter class to encrypt ViewState of Page

10. Can the HTML controls retian State accross postbacks?

No, by default HTML controls donot retain state accross postbacks.

11. Can you make HTML controls retain State accross postbacks?

Yes, HTML controls can retain State accross postbacks, if you convert HTML controls to Server Controls. There are 2 ways to convert HTML control to Server Controls.

1. Right click on the HTML Control and then click "Run As Server Control"
Or
2. Set runat="server" attribute for the Control.

12. Is ViewState supported in classic ASP?

No,ViewState is introduced in asp.net, it was not in classic asp.

When a form is submitted in classic ASP, all form values are cleared. Suppose you have submitted a form with a lot of information and the server comes back with an error. You will have to go back to the form and correct the information. You click the back button, and what happens.......ALL form values are CLEARED, and you will have to start all over again! The site did not maintain your ViewState.

When a form is submitted in ASP .NET, the form reappears in the browser window together with all form values. How come? This is because ASP .NET maintains your ViewState. The ViewState indicates the status of the page when submitted to the server.

13. Is ViewState of one page available to another page?

No, ViewState of a Page is available only in that page. You cannot access ViewState of one page from another page.

14. Can you programatically store and retrieve data from ViewState?

Yes. In ASP.NET you can programatically store and retrieve data from ViewState.See the example below

//Save the value in ViewState object
ViewState("SomeVar") = txtFirstName.text;

//Retrieve the value from ViewState object
String strFirstName = ViewState("SomeVar").ToString();

15. Can someone view the Page HTML source and read ViewState?

No. ViewState is base-64 encoded. Hence you cannot read ViewState. If you right click on the Page and View Source you will find __ViewState is base-64 encoded.

16. What happens during the Page_Init event?
The server controls are loaded and initialized from the Web form’s view state. This is the first step in a Web form’s life cycle.

17. In View state how can you make sure that view state in page can
not be tampered?

Or

Administrator wants to make a security check that no one has
tampered with ViewState, how can we ensure this?

Microsoft has provided two mechanisms for increasing the security of ViewState.
a. Machine Authentication Check (MAC) - tamper-proofing <%@Page EnableViewStateMac="true"%>
b. Encrypting the ViewState This encryption can only be applied at the machine.config level, as follows:


ASP.NET

1. Page Life Cycle Events
1. Page_PreInit
2. Page_Init
3. Page_InitComplete
4. OnPreLoad
5. Page_Load
6. Page_LoadComplete
7. OnPreRender
8. OnSaveStateComplete
9. Page_UnLoad

Page_Init -- Page Initialization

LoadViewState -- View State Loading

LoadPostData -- Postback data processing

Page_Load -- Page Loading

RaisePostDataChangedEvent -- PostBack Change Notification

RaisePostBackEvent -- PostBack Event Handling

Page_PreRender -- Page Pre Rendering Phase

SaveViewState -- View State Saving

Page_Render -- Page Rendering

Page_UnLoad -- Page Unloading

2. Types of Session state mode?

InProc mode, which stores session state in memory on the Web
server. This is the default.

StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the web application is restarted and also makes session state available to multiple web servers in a Web farm.

SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session
state available to multiple Web servers in a Web farm.

Custom mode, which enables you to specify a custom storage provider.

Off mode, which disables session state.

3. In which database sql server session will be stored?


Session state is stored in the tempdb database of SQL Server.

4. Is it possible to turn off cookies for one page?


By setting Cookie.Discard property false

Web Services

1. What is the difference between XML Web Services using ASMX and .NET remoting using SOAP?

- XML Web services are more restricted than objects exposed over .NET Remoting.
- XML Web services support open standards that target cross-platform use.
- XML Web services are generally easier to create and due to the restricted nature of XML Web services, the design issues are simplified.
- XML Web services support only SOAP message formatting, which uses larger XML text messages.
- Communication with .NET Remoting can be faster than XML Web service communication with a binary formatter.
- XML Web services are designed for use between companies and organizations.
- XML Web services don't require a dedicated hosting program because they are always hosted by ASP.NET.
- Consumers can use XML Web services just as easily as they can download HTML pages from the Internet. Thus there's no need for an administrator to open additional ports on a firewall as they work through MS-IIS and ASP.NET
2. Describe the three major components that make up a Web Service.

SOAP (Simple Object Access Protocol)
- UDDI (Universal Description, Discovery and Integration)
- WSDL (Web Services Description Language

3. What are Web Services?

Web services exposes functionality over internet using protocol such as HTTP. Web services can be accessed by two disparate applications from different platforms as they use SOAP protocol to expose the business functionality. SOAP is a platform independent protocol, so the consumer of the web services doesn’t have to know any implementation detail of web services based components. This is the reason why web services hosted on windows can even be accessed by LINUX consumer.
4. Is it possible to consume Java Web Service in .NET application
Yes it is possible because webservices are independent to language because its depends on WSDL and Soap. Because WSDL and Soap both supports XML and language are XML parsing capability and also access to HTTP protocol.

VB.Net

1. What is the difference between module and class module?


Standard Module: Properties methods and variable declare in this module can be accessed throughout the application.
Class Module: Properties Methods and variables declare in the class module can be accessed only after creating the object of the class. After creating the object you can access these properties and method from any applications both class and module are a collection of methods and properties. The major difference is that instances can be
created from a class in the form of objects, but not from a module. The scope of the members of a class is only for the lifetime of the object, but the scope of the members of a module exist for the life of the program


What is the .NET Framework?
The .NET Framework is set of technologies that form an integral part of the .NET Platform. It is Microsoft's managed code programming model for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes.

The .NET Framework has two main components: the common language runtime (CLR) and .NET Framework class library. The CLR is the foundation of the .NET framework and provides a common set of services for projects that act as building blocks to build up applications across all tiers. It simplifies development and provides a robust and simplified environment which provides common services to build application. The .NET framework class library is a collection of reusable types and exposes features of the runtime. It contains of a set of classes that is used to access common functionality.
What is CLR?

The .NET Framework provides a runtime environment called the Common Language Runtime or CLR. The CLR can be compared to the Java Virtual Machine or JVM in Java. CLR handles the execution of code and provides useful services for the implementation of the program. In addition to executing code, CLR provides services such as memory management, thread management, security management, code verification, compilation, and other system services. It enforces rules that in turn provide a robust and secure execution environment for .NET applications.
What is CTS?

Common Type System (CTS) describes the datatypes that can be used by managed code. CTS defines how these types are declared, used and managed in the runtime. It facilitates cross-language integration, type safety, and high performance code execution. The rules defined in CTS can be used to define your own classes and values.
What is CLS?

Common Language Specification (CLS) defines the rules and standards to which languages must adhere to in order to be compatible with other .NET languages. This enables C# developers to inherit from classes defined in VB.NET or other .NET compatible languages.
What is managed code?
The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime's functionality and enable you to write code that benefits from this managed execution environment. The code that runs within the common language runtime is called managed code.
What is MSIL?

When the code is compiled, the compiler translates your code into Microsoft intermediate language (MSIL). The common language runtime includes a JIT compiler for converting this MSIL then to native code.

MSIL contains metadata that is the key to cross language interoperability. Since this metadata is standardized across all .NET languages, a program written in one language can understand the metadata and execute code, written in a different language. 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.
What is JIT?


JIT is a compiler that converts MSIL to native code. The native code consists of hardware specific instructions that can be executed by the CPU.

Rather than converting the entire MSIL (in a portable executable[PE]file) to native code, the JIT converts the MSIL as it is needed during execution. This converted native code is stored so that it is accessible for subsequent calls.

What is portable executable (PE)?

PE is the file format defining the structure that all executable files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded and executed by Windows. PE is derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using the .NET Framework obey the PE/COFF formats and also add additional header and data sections to the files that are only used by the CLR.
What is an application domain?

Application domain is the boundary within which an application runs. A process can contain multiple application domains. Application domains provide an isolated environment to applications that is similar to the isolation provided by processes. An application running inside one application domain cannot directly access the code running inside another application domain. To access the code running in another application domain, an application needs to use a proxy.

How does an AppDomain get created?

AppDomains are usually created by hosts. Examples of hosts are the Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new AppDomain for every application. AppDomains can also be explicitly created by .NET applications.
What is an assembly?

An assembly is a collection of one or more .exe or dll’s. An assembly is the fundamental unit for application development and deployment in the .NET Framework. An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the CLR with the information it needs to be aware of type implementations.
What are the contents of assembly?

A static assembly can consist of four elements:

·         Assembly manifest - Contains the assembly metadata. An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to types and resources.

·         Type metadata - Binary information that describes a program.

·         Microsoft intermediate language (MSIL) code.

·         A set of resources.
What are the different types of assembly?

Assemblies can also be private or shared. A private assembly is installed in the installation directory of an application and is accessible to that application only. On the other hand, a shared assembly is shared by multiple applications. A shared assembly has a strong name and is installed in the GAC.

We also have satellite assemblies that are often used to deploy language-specific resources for an application.
What is a dynamic assembly?

A dynamic assembly is created dynamically at run time when an application requires the types within these assemblies.
What is a strong name?

You need to assign a strong name to an assembly to place it in the GAC and make it globally accessible. A strong name consists of a name that consists of an assembly's identity (text name, version number, and culture information), a public key and a digital signature generated over the assembly.  The .NET Framework provides a tool called the Strong Name Tool (Sn.exe), which allows verification and key pair and signature generation.
What is GAC? What are the steps to create an assembly and add it to the GAC?

The global assembly cache (GAC) is a machine-wide code cache that 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.

Steps

- Create a strong name using sn.exe tool eg: sn -k mykey.snk

- in AssemblyInfo.cs, add the strong name eg: [assembly: AssemblyKeyFile("mykey.snk")]

- recompile project, and then install it to GAC in two ways :

·         drag & drop it to assembly folder (C:\WINDOWS\assembly OR C:\WINNT\assembly) (shfusion.dll tool)

·         gacutil -i abc.dll
What is the caspol.exe tool used for?

The caspol tool grants and modifies permissions to code groups at the user policy, machine policy, and enterprise policy levels.
What is a garbage collector?

A garbage collector performs periodic checks on the managed heap to identify objects that are no longer required by the program and removes them from memory.
What are generations and how are they used by the garbage collector?
Generations are the division of objects on the managed heap used by the garbage collector. This mechanism allows the garbage collector to perform highly optimized garbage collection. The unreachable objects are placed in generation 0, the reachable objects are placed in generation 1, and the objects that survive the collection process are promoted to higher generations.

How do you prevent a class from being inherited?

In VB.NET you use the NotInheritable modifier to prevent programmers from using the class as a base class. In C#, use the sealed keyword.

Define Overriding?

Overriding is a concept where a method in a derived class uses the same name, return type, and arguments as a method in its base class. In other words, if the derived class contains its own implementation of the method rather than using the method in the base class, the process is called overriding.
Can you use multiple inheritance in .NET?

.NET supports only single inheritance. However the purpose is accomplished using multiple interfaces.
Why don’t we have multiple inheritance in .NET?
There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritance. So in order to implement multiple inheritance, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover multiple interface inheritance very much covers the benefits that multiple inheritance has.
What is an Interface?
An interface is a standard or contract that contains only the signatures of methods or events. The implementation is done in the class that inherits from this interface. Interfaces are primarily used to set a common standard or contract.
When should you use abstract class vs interface or What is the difference between an abstract class and interface?
I would suggest you to read this. There is a good comparison given over here.
What are events and delegates?
An event is a message sent by a control to notify the occurrence of an action. However it is not known which object receives the event. For this reason, .NET provides a special type called Delegate which acts as an intermediary between the sender object and receiver object.
What is business logic?
It is the functionality which handles the exchange of information between database and a user interface.


What is a component?Component is a group of logically related classes and methods. A component is a class that implements the IComponent interface or uses a class that implements IComponent interface.
What is a control?A control is a component that provides user-interface (UI) capabilities.

What are design patterns?Design patterns are common solutions to common design problems.

What is the global assembly cache (GAC)?GAC is a machine-wide cache of assemblies that allows .NET applications to share libraries. GAC solves some of the problems associated with dll’s (DLL Hell).

Can we force garbage collector to run ?
Ans :
System.GC.Collect() forces garbage collector to run. This is not recommended but can be used if situations arises.
 

What is reflection?
Ans:
All .NET assemblies have metadata information stored about the types defined in modules. This metadata information can be accessed by mechanism called as “Reflection”.System. Reflection can be used to browse through the metadata information.Using reflection you can also dynamically invoke methods using System.Type.Invokemember.


What is namespace used for loading assemblies at run time and name the methods?

 System.Reflection and System.Type.InvokeMember to invoke
the method.


application configuration and server configuration have different sessions then what will happend?


Application Configuration File Variables will over ride the values of server configuration file if allowoverride set as True, if  allowoverride is false then Application Configuration file variables cannot override the values of server configuration file.


can a class called with out namespace?

explicitly refer to a class without a namespace in C#

C# also has a global (or unnamed) namespace - you can use global:: to access your class:

You can create an alias for it as well:

using myEnv = global::Environment;
using sysEnv = System.Environment;

VB.NET's "shadows" keyword?

In VB.NET, the shadows keyword hides all the inherited functions,
regardless of signature.



We all know that the New keyword is used to shadow a function in the parent class. What it means is that in the child class, the method is treated as if it does not exist in the parent class. The question then arises as to what is the difference between shadowing and overriding? You can as well define a virtual method and override it in the child class. Why do we need New keyword?

The answer is that shadowing helps you "override" a function in a parent method even if that is not marked virtual. In other words, it helps you override a non virtual method in the child class.



Using the New Keyword to shadow a method in a parent class?


A typical use - Consider a class library being used by various modules in a project. There is a method which is being referenced by numerous modules and libraries. You need to make a change in that method but you are not sure if that is going to break the functionality of the modules already referencing that. So you define a class inheriting from the parent class and shadow the method using new keyword. You use your own shadowed method for your logic while not breaking any code due to your change.

What is ClickOnce?ClickOnce is a new deployment technology that allows you to create and publish self-updating applications that can be installed and run with minimal user interaction.
What is object role modeling (ORM) ?It is a logical model for designing and querying database models. There are various ORM tools in the market like CaseTalk, Microsoft Visio for Enterprise Architects, Infagon etc.
What is a private assembly?A private assembly is local to the installation directory of an application and is used only by that application.
What is a shared assembly?A shared assembly is kept in the global assembly cache (GAC) and can be used by one or more applications on a machine.
What is the difference between user and custom controls?User controls are easier to create whereas custom controls require extra effort.
User controls are used when the layout is static whereas custom controls are used in dynamic layouts.
A user control cannot be added to the toolbox whereas a custom control can be.
A separate copy of a user control is required in every application that uses it whereas since custom controls are stored in the GAC, only a single copy can be used by all applications.
Where do custom controls reside?
In the global assembly cache (GAC).
What is a third-party control ?A third-party control is one that is not created by the owners of a project. They are usually used to save time and resources and reuse the functionality developed by others (third-party).
What is a binary formatter?
Binary formatter is used to serialize and deserialize an object in binary format.
What is Boxing/Unboxing?
Boxing is used to convert value types to object.
E.g. int x = 1;
object obj = x ;
Unboxing is used to convert the object back to the value type.
E.g. int y = (int)obj;
Boxing/unboxing is quiet an expensive operation.

 What’ is the sequence in which ASP.NET events are processed?
Following is the sequence in which the events occur:-
• Page_Init.
• Page Load.
• Control events
• Page- Unload event.
Page_init event only occurs when first time the page is started, but Page Load occurs in subsequent request of the page.

 In which event are the controls fully loaded?


Page load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event.5
 How can we identify that the Page is Post Back?
Page object has an “IsPostBack” property, which can be checked to know that is the page posted back.

 How does ASP.NET maintain state in between subsequent request?


What is event bubbling?


Server controls like Data grid, Data List, and Repeater can have other child controls inside them. Example Data Grid can have combo box inside data grid. These child control do not raise there events by themselves, rather they pass the event to the container parent (which can be a data grid, data list, repeater), which passed to the page as “ItemCommand” event. As the child control send events to parent it is termed as event bubbling.

 How do we assign page specific attributes?
Page attributes are specified using the @Page directive.

 How do we ensure view state is not tampered?

Using the @Page directive and setting ‘EnableViewStateMac’ property to True.

 What is the use of @ Register directives?

@Register directive informs the compiler of any custom server control added to the page.

 What is the use of Smart Navigation property?

It’s a feature provided by ASP. NET to prevent flickering and redrawing when the page is posted back.

Note:- This is only supported for IE browser. Project is who have browser compatibility as requirements have to think some other ways of avoiding flickering.

What is AppSetting Section in “Web.Config” file?

Web.config file defines configuration for a web project. Using “AppSetting” section, we can define user-defined values. Example below defined is “Connection String” section, which will be used through out the project for database connection.

<Configuration>
<appSettings>
<add key="ConnectionString" value="server=xyz;pwd=www;database=testing" />
</appSettings>

(B) Where is View State information stored?

In HTML Hidden Fields.

(I) what is the use of @ Output Cache directive in ASP.NET.

It is used for caching. See more for Caching chapter.

(B) How can we create custom controls in ASP.NET?


User controls are created using .ASCX in ASP.NET. After .ASCX file is created you need to two things in order that the ASCX can be used in project:.


• Register the ASCX control in page using the <percentage@ Register directive.Example


<%@ Register tag prefix="Accounting" Tag name="footer" src="Footer.ascx" %>


• Now to use the above accounting footer in page you can use the below directive.


<Accounting: footer runat="server" />

(B) How many types of validation controls are provided by ASP.NET?

There are six main types of validation controls:-

RequiredFieldValidator
It checks whether the control have any value. It is used when you want the control should not be empty.

RangeValidator
It checks if the value in validated control is in that specific range. Example TxtCustomerCode should not be more than eight lengths.

CompareValidator
It checks that the value in controls should match some specific value. Example Textbox TxtPie should be equal to 3.14.

RegularExpressionValidator
When we want the control, value should match with a specific regular expression.

CustomValidator
It is used to define User Defined validation.
Validation Summary
It displays summary of all current validation errors on an ASP.NET page.

Note: - It is rare that some one will ask step by step all the validation controls. Rather they will ask for what type of validation which validator will be used. Example in one of the interviews i was asked how will you display summary of all errors in the validation control...just uttered one word Validation summary.

(B) Can you explain “AutoPostBack”?

If we want the control to automatically post back in case of any event, we will need to check this attribute as true. Example on a Combo Box change we need to send the event immediately to the server side then set the “AutoPostBack” attribute to true.

(B) How can you enable automatic paging in Data Grid?

Following are the points to be done in order to enable paging in Data grid:-
• Set the “Allow Paging” to true.
• In PageIndexChanged event set the current page index clicked.

Note: - The answers are very short, if you have implemented practically its just a revision. If you are fresher, just make sample code using Datagrid and try to implement this functionality.

(B) What is the use of “GLOBAL.ASAX” file?

It allows to execute ASP.NET application level events and setting application-level variables.

(B) What is the difference between “Web.config” and “Machine.Config”?

“Web.config” files apply settings to each web application, while “Machine.config” file apply settings to all ASP.NET applications.

(B) What is a SESSION and APPLICATION object?


Session object store information between HTTP requests for a particular user, while application object are global across users.