Is there a means to get the index of the first non-whitespace character in a string (or more generally, the index of the first character matching a condition) in C# without
There is a very simple solution
string test = " hello world";
int pos = test.ToList().FindIndex(x => char.IsWhiteSpace(x) == false);
pos will be 4
you can have more complex conditions like:
pos = test.ToList().FindIndex((x) =>
{
if (x == 's') //Your complex conditions go here
return true;
else
return false;
}
);