Some netizens asked to read some data from the txt file and then combine the data rows in a specific format. The original topic is as follows. The requirements just now were not clearly described. Later, they were completely supplemented.
Insus. NET thinks this topic can have the ability to read text pieces, so try to implement it. The method may not be the best.
First, create a class to process each line of text in a text file. Since each line of text is divided into two segments, two attributes are declared for storage. Static TryParse () is used to determine whether the text line meets the requirements. Empty rows are not processed. They are not empty rows. They must contain three spaces. Then, assign the first section to the first attribute E1, and then assign the combination of the second and third sections to the second attribute E2. Finally, write the override ToString () method again.
Next, we start to process a text file. First, we get the physical path of the text file and then read the file.
Returns an anonymous result.
Write the required lines of text into the result.
Finally, it is the output result set.
Webpage running effect: