Monday, 15 June 2015

C# Index was out of range. Must be non-negative and less than the size of the collection -



C# Index was out of range. Must be non-negative and less than the size of the collection -

recently doing project developing editor, why c# list can allow me using add together function, cant assign value indexing can help?

list<list<string>> datalist = new list<list<string>>(); .... datalist[tag.count-1]=datasublist;

is problem because you're trying assign doesn't exist. list isn't array, declare of specific size , can utilize part of made. since you've declared datalist new list nil in it, there isn't in can change. need use

datalist.add(datasublist);

an unrelated aside, noted in comments, can replace

line.substring(26, endofindex)

with

line.substring(26)

it default homecoming rest of string. allow remove endofindex variable.

c#

No comments:

Post a Comment