Hi friends,
Can anybody define the term member variable, class variable,instance variable,reference variable and field in C#.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Dec 3, 2011, 2:13 AM
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