string ss = "560-1350";//我想要截取出1350
或者ss也可能是一个整数string ss = "1350"
需要做判断!当ss等于1350是直接输入等于560-1350时截取后面的1350.

解决方案 »

  1.   

    不用判断:string ss = ss.Substring(ss.LastIndexof('-'),ss.length-1);
    //好象这么写,就这个意思。
      

  2.   


    string ss = "560-1350";
    string[] str = ss.Split('-');
    Console.WriteLine(str[str.Length-1]);
      

  3.   

    string ss = ss.Substring(ss.LastIndexof('-')>-1?0:ss.LastIndexof('-'),(ss.length-ss.LastIndexof('-'))>ss.length?0:ss.length-ss.LastIndexof('-')-1); 
      

  4.   

    string ss = "560-1350";
    int index=ss.IndexOf("-");
    ss=ss.Substring(index+1,ss.length-index-1);
    Response.Write(ss);