Hi Guys,
I am new To .NET Programming, Can anyone please explain me about object instantiation with the real time example ?
Thanks In Advance
Hi Guys,
I am new To .NET Programming, Can anyone please explain me about object instantiation with the real time example ?
Thanks In Advance
new object(); // instantiation
object o; //declaration
o = new object(); // assignment and instantiation
object p = new object(); //all three
See Example 2 here: http://en.wikipedia.org/wiki/Class_%28computer_science%29#C.23
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();