I have a text file from which I want to store Keys
and Values
in a String
array.
In this case, Key
is something like &
Basically, you do not want to split your entire string, but to skip all the content before encountering first ':' char plus one symbol (':' itself).
var data = line.Substring(line.IndexOf(':') + 1);
Or if you really want solution with Split:
var data = string.Join(":", line.Split(':').Skip(1));
Here, we first split the string into array, then skip one element (the one we are trying to get rid of), and finally construct a new string with ':' between elements in the array.