Why one value is only stored in a variable?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 18, 2013, 3:32 AM EST
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.