Hi friends,
Can anybody define the term member variable, class variable,instance variable,reference variable and field in C#.
Member variable,class variable and instance variable
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Satyapriya NayakRank #47 · 31.5K reputationPosted Dec 2, 2011, 9:13 PM EST
Instance variable: -A field declared without the static modifier is called an instance variable. An instance variable of a class comes into existence when a new instance of that class is created, and ceases to exist when there are no references to that instance and the instance's finalize (if any) has executed.
Field: -A field is a variable of any type that is declared directly in a class or struct. Fields are members of their containing type.
http://msdn.microsoft.com/en-us/library/ms173118.aspx
http://www.csharpuniversity.com/2008/10/14/class-variables-member-variables-and-instance-variables/
Reference type variables are named appropriately (reference) because the variable holds a reference to an object. In C and C++, you have something similar that is called a pointer, which points to an object. While you can modify a pointer, you can't modify the value of a reference - it simply points at the object in memory.
An important fact you need to understand is that when you are assigning one reference type variable to another, only the reference is copied, not the object. The variable holds the reference and that is what is being copied.Thanks