Mögliches Duplikat:
Strukturvariable in einem Dictionary ändern
Warum ist es so, dass
MyStruct test = new MyStruct();
test.Closed = true;
Funktioniert prima, aber
MyDictionary[key].Closed = true;
Zeigt einen "Cannot modify the expression because it is not a variable"-Fehler zur Kompilierungszeit?
Was ist an der Zuordnung in diesen beiden Fällen anders?
Note : MyDictionary
ist vom Typ <int, MyStruct>
Code für die Struktur:
public struct MyStruct
{
//Other variables
public bool Isclosed;
public bool Closed
{
get { return Isclosed; }
set { Isclosed = value; }
}
//Constructors
}