tags:

views:

62

answers:

3

Hi Guys,

I am new To .NET Programming, Can anyone please explain me about object instantiation with the real time example ?

Thanks In Advance

+3  A: 
new object(); // instantiation 
object o; //declaration
o = new object(); // assignment and instantiation

object p = new object(); //all three
Bob
Thank You Very Much
Anoop
A: 

See Example 2 here: http://en.wikipedia.org/wiki/Class_%28computer_science%29#C.23

Konamiman
+5  A: 
object handle = new object();

"handle" is not the object itself, but a handle to the object. This is quite important to understand :) You can have multiple handles to the same object; for example:

object handle1 = new object(); //Here's the instantiation
object handle2 = handle1; //No instantiation

//These methodcalls happens on the same instance of object.
handle1.ToString();
handle2.ToString();
cwap
Thank You Very Much
Anoop