1
Answer

Write an arry to a text file then read it back from that tex file in C#

Ask a question
yamid

yamid

15y
3.6k
1

Hi Friends,

I have a 3D array with n*m*k elements in each dimention(in C#).I want to write this array in a Text file with 5 columns in which the data should be print left to right and line by line one after other.( then read the text back to an equivalent array)

The i dimention has higher hierachy then j and k. 


--------------------------
Example
: suppose we have A[,,]= new double[4,3,2]

A[0,0,0]=1
A[1,0,0]=2
A[2,0,0]=3
A[3,0,0]=4

A[0,1,0]=5
A[1,1,0]=6
A[2,1,0]=7
A[3,1,0]=8

A[0,2,0]=9
A[1,2,0]=10
A[2,2,0]=11
A[3.2,0]=12

A[0,0,1]=13
A[1,0,1]=14
A[2,0,1]=15
A[3,0,1]=16

A[0,1,1]=17
A[1,1,1]=18
A[2,1,1]=19
A[3,1,1]=20

A[0,2,1]=21
A[1,2,1]=22
A[2,2,1]=23
A[3.2,1]=24

I want to write this array in a text file(delimited with TAB) like this:

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24
 Then read the text file back to an array B the same dimension as A.

 

Thanks for your help


Answers (1)