2009-11-14 270 views
0

我是新來的.NET編程,任何人都可以請解釋我關於對象實例與實時示例?對象實例化

回答

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

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

非常感謝你 – Anoop 2009-11-14 23:37:52

5
object handle = new object(); 

「處理」是不是對象本身,而是一個句柄的對象。這是理解相當重要的:)你可以對同一個對象有多個句柄;例如:

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

非常感謝你 – Anoop 2009-11-14 23:26:57