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

解决方案 »

  1.   

    you can use Substring is like Mid
    ==>
    you can use Substring, it is like Mid
      

  2.   

    string s = "hello,world!   ";string s1 = s.Substring(0,5);//same as left(5)
    string s2 = s.Substring(s.Length - 5,5);//same as right(5)string s3 = s.Trim();//same as trim()
      

  3.   

    String.Substring 方法  [C#]
    从此实例检索子字符串。重载列表
    从此实例检索子字符串。子字符串从指定的字符位置开始。[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.
      

  4.   

    String.Trim 方法  [C#]
    从此实例的开始位置和末尾移除一组指定字符的所有匹配项。重载列表
    从此实例的开始位置和末尾移除空白字符的所有匹配项。[C#] public string Trim();
    [从此实例的开始位置和末尾移除 Unicode 字符数组中指定的一组字符的所有匹配项。[C#] public string Trim(params char[]);