Creating Understanding and Educating Programmers, Developers and Technical Communities, one post at a time.

Friday, May 29, 2009

[Quick Tip] Session

During the development of Asp.Net application, developer don't need to instantiate any session. Session is automatically instantiated, you need to use them according to your requirement. Here, I am going to show you one simple example.

DataTable dt = new DataTable();

// what ever the table you want to put in dt

// assign dt value into session variable, make sure it is unique name,
// I have given dtSessionVariable as session variable name.
Session["dtSessionVariable"] = dt;

// To retrieve it from session, it require casting back to original type
DataTable dt = (DataTable)Session["dtSessionVariable"];

Monday, May 18, 2009

Friday, May 15, 2009


Structure is a lightweight class in C#. The following list details the differences between structures and classes.

  • implicity inherits from System.ValueType (always reside on stack)
  • are sealed and can not be inherited, and also cannot inherit classes and other structures
  • The default constructor of a structure cannot be replaced by a custom constructor.
  • Custom constructors of a structure must fully initialize the value of the structure.
  • Dont have a destructor
  • Field initialization is not allowed. Const members of a structure can be initialized.

Thursday, May 14, 2009


The Global.asax file(the ASP.NET application file) contains code for responding to application-level and session-level events raised by ASP.NET or by HTTP modules.

By default, the ASP.NET Framework maintains a pool of HttpApplication objects to service incoming page requests. A separate HttpApplication instance is assigned to each request.

If you prefer, you can create a custom HttpApplication class. That way, an instance of your custom class is assigned to each page request.

You can create custom properties in your derived class. These properties can be accessed from any page, control, or component. You also can handle any application events in your custom HttpApplication class.

You create a custom HttpApplication class by creating a special file named Global.asax in the root of your application. Following are few more detail about it.

  • It is optional file.
  • It must be located in the root directory. (file located in sub-directory is simply ignored)
  • Only one global.asax file per application. (you can not have more than one for an application.)

public class Global: System.Web.HttpApplication
//It is derived from HttpApplication base class

protected void Application_Start(Object sender, EventArgs e)
//lush(good) code

Sunday, May 10, 2009

void pointer

Pointer to void (void *) is a generic pointer capable of representing any pointer type. All pointer types can be assigned a pointer to void without casting. However, a pointer to void cannot be assigned directly to a pointer of another type - the void pointer must first be cast to proper pointer type.

A void * pointer can not be dereferenced.