2009-11-14 4 views
0

Je suis nouveau à Programmation .NET, Quelqu'un peut-il m'expliquer s'il vous plaît à propos de l'instanciation d'objet avec l'exemple en temps réel?instantiation d'objet

Répondre

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

object p = new object(); //all three 
+0

Merci beaucoup – Anoop

5
object handle = new object(); 

« poignée » n'est pas l'objet lui-même, mais une poignée à l'objet. C'est assez important à comprendre :) Vous pouvez avoir plusieurs poignées pour le même objet; Par exemple:

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(); 
+0

Merci beaucoup – Anoop

Questions connexes