user5468794 user5468794 - 2 months ago 8
C# Question

Remove chars in beginning of string array

I am opening up a txt file and writing it to a string array. The issue is how is do I do the equivalent of a string,

lines.Remove(0,6)
with a string array? I know I have to loop through each [] in the array but then how do I get my desired result?

text file:


12345;9/19/2016 something.pdf


how I'm getting the file:

string[] lines = File.ReadAllLines(@"\\ecmvmdev21\text.txt");


Desired output:


9/19/2016 something.pdf

Answer

Loop through the array of strings as you said, then inside your for loop:

lines[i] = lines[i].Substring(6);

Comments