why one value is only stored in a variable?
why one value is only stored in a variable?
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.
VulpesPosted Feb 18, 2013, 8:32 AM
In the case of value types (structs, enums), the variable stores the value itself.
In the case of reference types (classes, arrays, delegates), the variable stores a reference (or pointer) to where an object of that type is stored on the managed heap.
In both cases, you can effectively store more than one value.
For example, you could define a struct which contains several fields:
struct MyStruct
{
public int MyInt;
public string MyString;
}
In the case of a class, you could use an array or some other type of collection (list, dictionary etc) to store multiple values.