Monday 15 June 2015

c# 4.0 - Struct store large chunk of data -



c# 4.0 - Struct store large chunk of data -

i have info file millions of rows , wanted read , store in struct.

public struct sample { public int a; public datetime b; } sample[] sample = new sample[];

this definition gives me error "wrong number of indicies inside[]; expected 1"

how store info in struct (with less memory usage)? array best of else?

var reader = new streamreader(file.openread(@"c:\test.csv")); while (!reader.endofstream) { var line = reader.readline(); var values = line.split(';'); }

in order allocate array, need specify how many elements holds. that's error telling you.

if don't know size, can utilize list<t> grow needed. internally list<t> implemented using t[] means look-up stand point acts array. however, work of reallocating larger arrays needed handled list<t>.

c#-4.0

No comments:

Post a Comment