i am doing a project. I use StreamReader to read my content in one file.
i need to change tht file into the string type. Then, i need to change the string type to string array....who know how to do this one....
Yo, I`m did the code for you. I hope you like it. I put some effort into it today (yest. didnt have time, sorry).
To test it, create a win form, and put two labels on it. But dont exagurate with the numbers (just for a text, use maybe a … Read More
i am doing a project. I use StreamReader to read my content in one file.
i need to change tht file into the string type. Then, i need to change the string type to string array....who know how to do this one....
i need to do in C# window form application.
thanks ..
private void GettingFileContent()
{
string path = @"C:\1\test3.txt";
//example of two different arrays:
//for string array (string[]) you need to define the lenght of it
//for the generic list you dont need to
//1.
int rows = File.ReadAllLines(path).Length;
string[] strArray = new string[rows];
//2.
List<string> listArray = new List<string>();
using (StreamReader sr = new StreamReader(path))
{
string line;
int count = 0;
while ((line = sr.ReadLine()) != null)
{
strArray[count++] = line;
listArray.Add(line);
}
}
}
OK....Now, I have many group of numbers(eg. 123 234 345 456 234 123....).I store them in one text file. When I open the text file,the group of numbers are arranged in horizontal.I want change those group of numbers to string array so that I can split them to one group of numbers and arrange in vertical.
Example:
123
234
345
456
234
123
......
so I need to change the file content to string type. After that, I need to change them to string array and use split method to do the splitting .So that, the group of numbers will change to vertical like i mention above.
but I tried many time but still cannot get it.
so you can help me...?
Do you have only one line of numbers in the text file?
And why do you need them in "vertical" position. You know, horizontal and vertical for computer means nothing. This is only you who imagine them to be arranged this way.
This example converts and puts a string into an array (like horizontal way).
Did you mean something like that:
string path = @"C:\1\test6.txt";
using (StreamReader sr = new StreamReader(path))
{
string allText = null;
string line;
while ((line = sr.ReadLine()) != null)
allText += line;
string[] array = allText.Split(' ');
}
oo..
I got many lines of numbers. (in horizontal)
one line could have many groups of numbers.
I need to change to the vertical lines..
BTW, thanks for helping me.
APLX is a very complete implementation of the APL programming language from MicroAPL. The company stopped producing it in 2016 and it has been taken over by Dyalog. While Dyalog ...