Answer the question
In order to leave comments, you need to log in
C# loading txt into array and division by sign?
How to do so that he would
press the button, he would download a file in which the base, in it 2 words are separated by a sign,
also in the text line by line.
Example
hello1: hello2
hello1: hello2
I need 1 hello to display in the first textbox and 2 will display word 2.
At the same time, it should delete the previous one after performing some actions.
Answer the question
In order to leave comments, you need to log in
I think Split() and ReadLine() will help you.
In fact, are there any developments? The condition is not completely clear, what and who should delete and after what actions?
Something like this (I write right here - because there may be "mistakes"):
string[] lines = File.ReadLines("c:\\file.txt");
var pairs = new List<KeyValuePair>();
foreach (var line in lines) {
string[] split = line.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
if( split.Length != 2) continue;
var pair = new KeyValuePair<string, string>(split[0], split[1]);
pairs.Add(pair);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question