I have a string consist of integer numbers followed by “|” followed by some binary data.
Example.
321654|<some binary data here>
How do i get the numbers in front of the string in the lowest resource usage possible?
i did get the index of the symbol,
string s = "321654654|llasdkjjkwerklsdmv"
int d = s.IndexOf("|");
string n = s.Substring(d + 1).Trim();//did try other trim but unsuccessful
What to do next? Tried copyto but copyto only support char[].
Assuming you only want the numbers before the pipe, you can do:
(Make it
d + 1if you want the pipe character to also be included.)I might be wrong, but I think you are under the impression that the parameter to
string.Substring(int)represents “length.” It does not; it represents the “start-index” of the desired substring, taken up to the end of the string.