value type && reference type

1.value type: there are data type that  base inside system,for example  int, string , char , float
2.reference type: there are other data type that packing base inside type ---->value type ,it is not contain type's instance, only contain type's reference.
 
3.we can create two value's variable of int  i and j
 
int i = 10;
int j = 8;
 
memory location :
 
---------- 0x00000
---------- 0x00001
10       0x00002
---------- 0x00005
8         0x00006
 
i  and j entire independence in memory, allocate independency location in memory.
 
if we change one of these variables,the other is not influence.
int j = i;
 
these variables between is not relation else.
 
4.however , reference type is different. for example:
--------------------------------------------------------------------------------------
myClass a = new myClass;
myClass b = a;
--------------------------------------------------------------------------------------
 
Now , the class is C# reference type, so "a" is "myClass"'s reference,
the first line create this "myClass" instance, and the "a" point to this instance, in other words,
this "a" is reference of "myClass".
this second line use "b" of refernce  point to that instance of "a"  created also.
posted on 2005-06-30 18:02  Arthur_wuancheng(大步牛)  阅读(1023)  评论(0编辑  收藏  举报