Convert.ToInt32(string)or 
int.Parse(string)

解决方案 »

  1.   

    和我知道的一摸一样,但是,下面的这段验证代码怎么都不成功
    private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
    {
    if(int.Parse(args.Value) > int.Parse(Label3.Text))
    {

    CustomValidator1.IsValid = false; }
    }
      

  2.   

    System.Convert.ToInt32(string)
    //
    int.Parse(string)与cmsoft(韦小宝是我的老乡.net)的一样,同意他的说法!
      

  3.   

    int.Parse(string),类型转换前先判断是否为空
      

  4.   

    先判断是否为空
    cint(string)
      

  5.   

    如果有意义的话可以用System.Convert.ToInt32(string)
    无意义就没法说了
      

  6.   

    使用int.parse会出现一些问题,容易引起一些甭掉的错误。最好写个函数将int.parse包装一下try
    {
        nValue = Int.Parse(obInt.ToString());
    }
    catch(Exception)
    {
        nValue = nDefault;
    } }