I have a line like this:
114765 * 3 * 659300 * 01 * 17/01/2013 * * 1 * Chuck Norris * Chuck Norris Jr* Owner * 1 * 28/04/1983 * Conjuge * * * 16/1/2013 * 1 * Quadro Social *
As you can see, the content/fields are separted by * they are fields like matriculation, name, dependent's name, category etc… I’d like to know how could I ´read` it, one by one ?
Also I need to reorder this and write a new file.txt, with these content reordered and without the *… I’m totally lost !
After I read it and remove the * I need to replace them like \field\:
\114765\\3\\659300\\01\\17/01/2013\\1\\Chuck Norris\
I tried substring() and StreamWriter StreamReader ReadLine but I couldn’t do what I need ;\
Use
String.Splitto get astring[]of the columns. You can useString.Jointo join all parts together to a new string andFile.WriteAlltextorFile.WriteAllLinesto write it back.So you need to replace the
*with\:Demo
Result:
Update:
If you want to ignore parts that are empty(caused by two consecutive
* *in the string), then you can use this code:That’ll result in:
That is
Enumerable.Skip: