संभव डुप्लिकेट:
Modify Struct variable in a Dictionaryअसाइनमेंट
ऐसा क्यों है कि
MyStruct test = new MyStruct();
test.Closed = true;
बहुत अच्छा काम करता है, लेकिन
MyDictionary[key].Closed = true;
"अभिव्यक्ति को संशोधित नहीं कर सकता क्योंकि यह एक चर नहीं है" संकलन समय में त्रुटि दिखाता है?
इन दो मामलों में असाइनमेंट के बारे में अलग क्यों है?
नोट: MyDictionary
प्रकार का है <int, MyStruct>
struct के लिए कोड:
public struct MyStruct
{
//Other variables
public bool Isclosed;
public bool Closed
{
get { return Isclosed; }
set { Isclosed = value; }
}
//Constructors
}
अधिक कोड दिखाएं .. – Zabba
@Zabba, अधिक कोड के लिए संपादित किया गया। – soandos
डाउनवॉटर टिप्पणी कृपया? – soandos