I would just go with something like:
if (str.StartsWith(" ") || str.StartsWith("\t")) { ... }
or
if ((str[0] == ' ') || (str[0] == "\t")) { ... }
I really prefer the former, since you don't have to worry about issues with empty strings.
If you want to handle a more complicated case in the future, you can use regular expressions, for example:
if (Regex.IsMatch (str, @"^\s")) ...
This can be changed to handle arbitrarily complex cases, although it is a bit like killing flies with a thermonuclear warhead for your specific case.
source share