我有一個列表是C#更新屬性
public static List<registry> regs = new List<registry>();
public struct registry
{
public int from;
public int rows;
public bool isValid;
public DateTime date;
public List<T> result;
public bool ok;
}
我碰到使用下面的代碼的REG註冊表:
registry x = regs.SingleOrDefault(p => p.from == from && p.rows == rows);
if (x.isValid == false) //checking if its default
{
regs.Add(new registry() { ok = true});
x = regs.Last();
}
的話,我想更新單值。我試圖簡單地更新值,但它不起作用。
x.isValid = true;
它只更新X,而不是列表。我該怎麼辦?
謝謝,將其更改爲類並工作正常。 – BernardoGO