0
Reply

Get operator for multi dimentional array

H

H

Apr 28 2006 12:46 PM
1.5k

This is the read from file class
CODE
public class ReadFromFile
{
FileStream f = null;
string fileName = "c:\\myData.data";
char [] separator = {' '};
string [] strArray;
int [,] pattern;
int [,] target;
int total = 0;
int count=1;
public ReadFromFile()
{
try
{
f = new FileStream(fileName,FileMode.Open,FileAccess.Read);
StreamReader r = new StreamReader(f);
string data = r.ReadLine();
for (int s=0;s {
strArray = data.Split(separator);
pattern = new int [count,strArray.Length-16];
target= new int [count,16];
for (int i = 0; i {
pattern[s,i] = Convert.ToInt32(strArray[i]);
}
for (int d = strArray.Length-16; d {
target[s,total] = Convert.ToInt32(strArray[d]);
total++;
}
data = r.ReadLine();
if(data !=null)
{
count++;
total = 0;
}
}
r.Close();
f.Close();

}
catch(IOException e)
{
Console.WriteLine(e.ToString());
}
finally
{
if ( f != null)
{
f.Close();
}
}
}


public int [,] inputDataArray
{
get
{
return this.pattern;
}

}
public int [,] outputDataArray
{
get
{
return this.target;
}

}

}



the problem is when i need to get the values of the any array of the above class to copy is to another array it gives me that all arrays og value zero except the last array wich give me the correct value

CODE
ReadFromFile g = new ReadFromFile();


int [,] inputArray= g.inputDataArray;
int [,] outputArray = g.outputDataArray;



what i should do ??