how to get rid of compiler error: C# use of unassigned local variable? -



how to get rid of compiler error: C# use of unassigned local variable? -

i have questions why c# doesn't coordinates[j] part , can it.

string[] lines = system.io.file.readalllines(@"c:\users\sp\dropbox\projecteuler\102\p102_triangles.txt"); string[] coordinates_str; double[] coordinates; //contains coordinates each line a1(x,y), a2(x,y), a3(x,y) long ln = lines.length; console.writeline("length: " + ln.tostring()); (int = 0; < ln; i++) { console.write(i); console.write(lines[i]); coordinates_str = lines[i].split(','); (int j = 0; j < 6; j++) { coordinates[j] = convert.todouble(coordinates_str[j]); } }

you assign values elements of coordinates without allocating storage first

double[] coordinates = new double[6];

so far have said coordinates reference array of doubles, have not said how big array (you have not allocated storage).

c# compiler-errors unassigned-variable

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -