I have developed this class to read from file
public
class ReadFromFile{
FileStream f =
null; string fileName = "c:\\myData.data"; char [] separator = {' '}; string [] strArray; public int [,] pattern ; public int [,] target; int total = 0; static int count=1; static int num = 0; 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<count;s++){
total = 0;
strArray = data.Split(separator);
pattern =
new int [count,strArray.Length-16];num = strArray.Length-16;
target=
new int [count,16]; for (int i = 0; i <strArray.Length-16;i++){
pattern[s,i] = Convert.ToInt32(strArray[ i ]);
}
for (int d = strArray.Length-16; d<strArray.Length; d++){
target[s,total] = Convert.ToInt32(strArray[ d ]);
total++;
}
data = r.ReadLine();
if(data !=null){
count++;
}
}
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 use the following method
ReadFromFile g =
new ReadFromFile();int
[,] inputDataArray = g.inputDataArray; int[,] outputDataArray = g.outputDataArray;
to copy the miltidimentional array from First class to another class it returns the all the values in all the arrays to be zero exept the last one which returnes the correct array
what is the reason for that and how i can correct it
Regards HAS

copying multidimentional array to another one
Sam88Jeep
thank you John
it's working now
Tom Mulcahy - MSFT
Don't forget to mark replies as answers when it is the answer to your question. It helps all when searching the forums after answers.
I already did it for you.
Mike Kieffer
as far as I can tell from a quick read of your code, you are doing this:
read something
count=1;
for (s=0; s<count; s++)
{
create new pattern array
create new target array
// fill array
// ...
read more
if something was read: count++
}
Well obviously, if you can read more, on the next entry of the loop you overwrite your just filled arrays and replace them with new ones as you recreate the arrays in each loop. That is why only the last read is in the array and everything else is gone. You either have to create the arrays outside the loop in the needed size or if you recreate them, you have to copy the old array into the new larger one otherwise you will lose your previously read data.