H
Hendri Adriaens
Hi,
I want to write a method to read the first column from a textfile and output
them in 2 arrays to the main program. I don't know the length of the column
beforehand. I use out to avoid needing to assign the array a value, but
still, I get the following complaint:
Use of unassigned out parameter 'variabelen'.
My code is below. I don't use it actually, I want to assign it a value. I
hope you can help.
Thanks, best regards,
-Hendri Adriaens.
static void Main(string[] args)
{
string[] variabelen;
leesSchattingen("m1_IB_m.txt", out variabelen);
leesSchattingen("m1_IB_v.txt", out variabelen);
}
static void leesSchattingen(string bestandsNaam, out string[] variabelen)
{
try
{
TextReader tr = new StreamReader(bestandsNaam);
string regel;
int i = 0;
while ((regel = tr.ReadLine()) != null)
{
string[] cellen = regel.Split('\t');
if (cellen[0] != "")
{
Console.WriteLine(cellen[0] + '\t' + cellen[1]);
variabelen = cellen[0];
i++;
}
}
tr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Environment.Exit(1);
}
}
I want to write a method to read the first column from a textfile and output
them in 2 arrays to the main program. I don't know the length of the column
beforehand. I use out to avoid needing to assign the array a value, but
still, I get the following complaint:
Use of unassigned out parameter 'variabelen'.
My code is below. I don't use it actually, I want to assign it a value. I
hope you can help.
Thanks, best regards,
-Hendri Adriaens.
static void Main(string[] args)
{
string[] variabelen;
leesSchattingen("m1_IB_m.txt", out variabelen);
leesSchattingen("m1_IB_v.txt", out variabelen);
}
static void leesSchattingen(string bestandsNaam, out string[] variabelen)
{
try
{
TextReader tr = new StreamReader(bestandsNaam);
string regel;
int i = 0;
while ((regel = tr.ReadLine()) != null)
{
string[] cellen = regel.Split('\t');
if (cellen[0] != "")
{
Console.WriteLine(cellen[0] + '\t' + cellen[1]);
variabelen = cellen[0];
i++;
}
}
tr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Environment.Exit(1);
}
}