Substring a string from the end of the string
s = s.Substring(0, Math.Max(0, s.Length - 2))
to include the case where the length is less than 2
You can do:
string str = "Hello Marco !";
str = str.Substring(0, str.Length - 2);
s = s.Substring(0, Math.Max(0, s.Length - 2))
to include the case where the length is less than 2
You can do:
string str = "Hello Marco !";
str = str.Substring(0, str.Length - 2);