You could use something like this:
Remove the returns if there are any
string[] check = test.Replace("\r", "").Split('\n');
if(check[0] == "1")
or split by new line and take the character in the array and check that.
string[] check = test.Split('\n');
if(check[0][0] == '1')
I would use option two.
EDIT:
Or something like this, but its a bit OTT and you get all of the \r\n
char[] check = test.SplitMeUp();
if(check[0] == '1')
static class Extensions
{
public static char[] SplitMeUp(this string str)
{
char[] chars = new char[str.Length];
for (int i = 0; i < chars.Length; i++)
chars[i] = str[i];
return chars;
}
}
EDIT:
Something else to filter out specific characters
public static char[] SplitMeUp(this string str, char[] filterChars = null)
{
List<Char> chars = new List<char>();
for (int i = 0; i < str.Length; i++)
{
if(filterChars != null && filterChars.Length > 0 && filterChars.Contains(str[i]))
continue;
chars.Add(str[i]);
}
return chars.ToArray();
}
and use it like
char[] check = test.SplitMeUp(new char[] {'\r', '\n'});
if(check[0] == '1')
it will ignore all of those \r\n and just split everything up.