Fast and clever way to get the NON FIRST segment of a C# string

c#, split, string

Solution

try

string X = "THIS IS AN AMAZING STRING";
string Y = (X.IndexOf ( " " ) < 0) ? string.Empty : X.Substring (X.IndexOf ( " " )  + 1); // Y = IS AN AMAZING STRING

As per comment (IF `X` is guaranteed to be a valid string with at least one space) a simpler version without checking etc.:

string Y = X.Substring (X.IndexOf ( " " )  + 1); 

Problem

I do a `split(' ')` over an string and I want to pull the first element of the returned string in order to get the rest of the string. f.e. `"THIS IS AN AMAZING STRING".split(' ');` I want to get all the words but THIS. This is: IS AN AMAZING STRING The string will always have at least one blank space between the first and the second word because I will put it hard coded Is there a function that makes this? thank you

Original source