比如Label1.Text="第1页";现在要把“第1页”中的1取出来,不知有何方法

解决方案 »

  1.   

    这个东西,不同情况有不同取法,一般都用Substring吧,,好像!~~~
      

  2.   


     string str = "第1页";
                str = str.Substring(1, 1);
      

  3.   

    我觉得用string.lenth 取出字符串长度,再进行截取。
      

  4.   

    正则取数字
    string test = @"第1页";            
    Regex reg = new Regex(@"(?is)第(?<x>\d+)页");
    MatchCollection mc = reg.Matches(test);
    foreach (Match m in mc)
    {
       Console.Write(m.Groups["x"].Value);
    }