【发布时间】:2011-11-08 14:48:39
【问题描述】:
我有这个代码:
IList<string> stelle = stelleString.Split('-');
if (stelle.Contains("3"))
stelle.Add("8");
if (stelle.Contains("4"))
stelle.Add("6");
但似乎 IList 在 .Split() 之后具有固定大小:System.NotSupportedException: Collection was of a fixed size.
我该如何解决这个问题?
【问题讨论】:
-
string.Split()返回一个字符串数组。数组的大小是固定的,因此您会遇到异常。 -
这是由于 .NET 中的错误设计决策:stackoverflow.com/questions/5968708/why-array-implements-ilist/…
标签: c# collections ilist