Interview questions

Q) In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events?  INIT, PageLoad, Prerender , UNload.

Q) 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

Q) What is AutoPostBack?  If you want a control to postback automatically when an event is raised, you need to set the AutoPostBackproperty of the control to True.

Q) Suppose you want an ASP.NET function (client side) executed on the MouseOver event of a button. Where do you add an event handler?  The event handler is added to the Add() method of the Attributes property.

Q) How can you implement the postback property of an ASP.NET control?  You need to set the AutoPostBack property to True to implement the PostBack property of controls.

Q) What are the event handlers that can be included in the Global.asax file?  The Global.asax file contains some of the following important event handlers:

  • Application_Error
  • Application_Start
  • Application_End
  • Session_Start
  • Session_End

Q) When we execute a Web page, it passes from the following stages, which are collectively known as Web page lifecycle:


  • Page request – During this stage, ASP.NET makes sure the page either parsed or compiled and a cached version of the page can be sent in response
  • Start – During this stage sets the Request and Response page properties and the page check the page request is either a postback or a new request
  • Page Initialization – During this stage, the page initialize and the control’s Unique Id property are set
  • Load – During this stage, if the request is postback, the control properties are loaded without loading the view state and control state otherwise loads the view state
  • Validation – During this stage, the controls are validated
  • Postback event handling – During this stage, if the request is a postback, handles the event
  • Rendering – During this stage, the page invokes the Render method to each control for return the output
  • Unload – During this stage, when the page is completely rendered and sent to the client, the page is unloaded.

What’s the use of Response.Output.Write()? We can write formatted output  using Response.Output.Write().

List the events in page life cycle.
  1) Page_PreInit
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad
5) Page_Load
6) Page_LoadComplete
7) Page_PreRender
Differentiate strong typing and weak typing
In strong typing, the data types of variable are checked at compile time. On the other hand, in case of weak typing the variable data types are checked at runtime. In case of strong typing, there is no chance of compilation error. Scripts use weak typing and hence issues arises at runtime.
List all templates of the Repeater control.
  • ItemTemplate
  • AlternatingltemTemplate
  • SeparatorTemplate
  • HeaderTemplate
  • FooterTemplate
What are the components of ADO.NET?
The components of ADO.Net are Dataset, Data Reader, Data Adaptor, Command, connection.

What is the difference between ExecuteScalar and ExecuteNonQuery?

ExecuteScalar returns output value where as ExecuteNonQuery does not return any value but the number of rows affected by the query. ExecuteScalar used for fetching a single value and ExecuteNonQuery used to execute Insert and Update statements.

c# Interview Questions

What’s the difference between the Debug class and Trace class?
Documentation looks the same.  Use Debug class for debug builds, use Trace class for both debug and release builds.

Can you declare an override method to be static if the original method is not static?
No.  The signature of the virtual method must remain the same.  (Note: Only the keyword virtual is changed to keyword override)

What is the difference between a Struct and a Class?
Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval.  Another difference is that structs cannot inherit.

What’s the difference between an interface and abstract class?
In an interface class, all methods are abstract – there is no implementation.  In an abstract class some methods can be concrete.  In an interface class, no accessibility modifiers are allowed.  An abstract class may have accessibility modifiers.

When do you absolutely have to declare a class as abstract?
1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
2.  When at least one of the methods in the class is abstract.

What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array.  The CopyTo() method copies the elements into another existing array.  Both perform a shallow copy.  A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array.  A deep copy (which neither of these methods performs) would create a new instance of each element’s object, resulting in a different, yet identacle object.

Note: MemberwiseClone() also creates a new copy but its a shallow copy. To perform a deep copy class should be marked as serializable and the object to be copied should be serialized and deserialized.

Explain ACID rule of thumb for transactions.
A transaction must be:
1. Atomic – it is one unit of work and does not dependent on previous and following transactions.
2. Consistent – data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t.
3. Isolated – no transaction sees the intermediate results of the current transaction).
4. Durable – the values persist if the data had been committed even if the system crashes right after.

When should you call the garbage collector in .NET?
As a good rule, you should not call the garbage collector.  However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory.  However, this is usually not a good practice.

Note:  GC can be implemented using Finalize or extend the idisposable interface  and implement the dispose() function . Finalize method is nothing but a destructor such as ~myClass(){}. GC.Collect()  can be used to force Garbage Collection.

How do you convert a value-type to a reference-type?
Use Boxing.

Boxing vs Unboxing

Boxing is the process of converting a value type to the type object.When the CLR boxes a value type, it wraps the value inside a System.Object and stores it on the managed heap. Unboxing extracts the value type from the object. Boxing is implicit; unboxing is explicit.

int i = 123;
// The following line boxes i. 
object o = i;

o = 123;
i = (int)o;  // unboxing

In relation to simple assignments, boxing and unboxing are computationally expensive processes. When a value type is boxed, a new object must be allocated and constructed.

Unboxing is an explicit conversion from the type object to a value type or from an interface type to a value type that implements the interface. An unboxing operation consists of:

Checking the object instance to make sure that it is a boxed value of the given value type.

Copying the value from the instance into the value-type variable.

The following statements demonstrate both boxing and unboxing operations:

int i = 123;      // a value type 
object o = i;     // boxing 
int j = (int)o;   // unboxing

For all your application development needs, visit for a fiscally conscious proposal that meets your needs ( So I can keep this blog going as well!!!!)

Alternatively click through the link   if you found this article interesting. (This will help the companies Search engine rankings)

An ode to st. Chantix

I have been smoking for about 12 years. For a long time I refused to believe that I was a smoker. What started as an idle past time with friends over a cup of coffee has effectively become the excuse for everything. Feeling good, bad, hungry…have a smoke. It even helps to alleviate a blocked nose.. well so it seems…until its too late. Under doctors orders (for medical reasons), I had to quit smoking. Enter Chantix…the one stop solution to nicotine addiction….well almost. For the record this was the third time I am on Chantix. The first two times were a phenomenal success. I stayed off it for three to four months and started it again…WHY??? I DON’T KNOW, BUT I DID.

The reason for this post is to warn smokers and the users of Chantix. The third time on Chantix was like a nightmare. The drug its was not working for me. The first two times, I hardly had the urge to smoke, but this time it did not have that effect. I was smoking well beyond the advertised 7 days. My heart was a mess. I couldn’t take seven steps without going through heavy heart palpitations. I had never experienced that before. Climbing steps was even worse. I would feel like I was going to faint. I seriously thought that my heart was giving up on me.

Fortunately I started goggling on Chantix and saw some web responses from others. I got off Chantix just 2 days back (after using it for 2 weeks) and I can already feel the difference. I feel so much better. At the end of the day, my advice is you have to WANT and NEED to quit. Nothing else works. Its been 2 days since I stopped Chantix, and the the urge to smoke is mind numbing, but I am not going back there ever again.