you can use Substring is like Mid, you can use it to achieve Right and LeftString s = " sdfsf ";
s = s.Trim();
s = s.Substring(1,4); //Mid
s = s.Substring(0,4);//Left 4
s = s.Substring(s.Length - 3);//Right s
s = s.Trim();
s = s.Substring(1,4); //Mid
s = s.Substring(0,4);//Left 4
s = s.Substring(s.Length - 3);//Right s
==>
you can use Substring, it is like Mid
string s2 = s.Substring(s.Length - 5,5);//same as right(5)string s3 = s.Trim();//same as trim()
从此实例检索子字符串。重载列表
从此实例检索子字符串。子字符串从指定的字符位置开始。[C#] public string Substring(int);从此实例检索子字符串。子字符串从指定的字符位置开始且具有指定的长度。[C#] public string Substring(int, int);
示例
[C#]
String myString = "abc";
bool test1 = String.Compare(myString.Substring(2, 1), "c") == 0; // This is true.
myString.Substring(3, 1); // This throws ArgumentOutOfRangeException.
bool test2 = String.Compare(myString.Substring(3, 0), String.Empty) == 0; // This is true.
从此实例的开始位置和末尾移除一组指定字符的所有匹配项。重载列表
从此实例的开始位置和末尾移除空白字符的所有匹配项。[C#] public string Trim();
[从此实例的开始位置和末尾移除 Unicode 字符数组中指定的一组字符的所有匹配项。[C#] public string Trim(params char[]);