Welcome To Shadab's Blog

Programming Blog to learn C# , java, Sql Server 2005 and many more things.





About Me

My photo
Bokaro, Jharkhand, India

Thursday, November 25, 2010

How to create object in C# programming ?

First of all I want to say sorry to all bcoz I m writting this blog after a long time.

Today I want write how to create object(instance) in programming language.
In last post i have written what is object?

For creating object we have to write  following line of code

   classname objectname=new classname(); 

After writting this code we can call method or access variable of that class
here classname refers name of class .
and object name refers name of object.
new is a key word that allocates memory for the object.

to clear understand see following code below.

class ABC
{
          public static void Main()
         {
                 ABC obj=new ABC(); //here obj is actual object.
          }
}

To call a method in  C# and how to access variable in C# we will learn next day.