The Split
method returns an array, and you can't resize an array.
You can create a List<string>
from the array using the ToList
extension method:
IList<string> stelle = stelleString.Split('-').ToList();
or the List<T>
constructor:
IList<string> stelle = new List<string>(stelleString.Split('-'));
Besides, you probably don't want to use the IList<T>
interface as the type of the variable, but just use the actual type of the object:
string[] stelle = stelleString.Split('-');
or:
List<string> stelle = stelleString.Split('-').ToList();
This will let you use exactly what the class can do, not limited to the IList<T>
interface, and no methods that are not supported.
string.Split()
returns a string array. Arrays are of fixed size, hence the exception you're getting. – Sharpeyed