怎么样把 string temp = "10001" 
转为int  Int32.Parse(temp)这样是错的
很菜,很郁闷~! 

解决方案 »

  1.   

    int i = Int32.Parse(temp);不会错的。错误是因为别的。
      

  2.   

    我一般用int.Parse(string) 应该不会错啊
      

  3.   

    应用另一种即可:int Dz = Convert.ToInt16(Nian)
      

  4.   

    try:->   Int32.Parse(temp.Trim())
    是不是你的串里有空格什么的啊.
      

  5.   

    同意楼上
    Int32.Parse(temp.Trim())或者用 Convert.ToInt32(temp.Trim())
    应该不是这个出错,你把出错提示贴一下看看
      

  6.   

    Int32.Parse(temp.Trim()) !!
      

  7.   

    int i=-1;
    if(int.tryparse(temp,out i)==true) 
    i就是你转换后的值
      

  8.   

    不会错,错的话是因为你贴出来的字符串不是出错的字符串。
    Int32.Parse(temp或者是这里是全角的原因? 呵呵 
      

  9.   

    Int32.Parse(obj)是专门把字符串obj转整型的,没错
    Convert.ToInt32(obj) obj可以是很多类型,比如对象什么的。
      

  10.   

    谢谢大家 知道错那了 
    protected void Grbroad_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            string brtypeid = Grbroad.DataKeys[e.NewSelectedIndex]["brtypeid"].ToString();
            Response.Redirect("Add_Hysort.aspx?brtypeid='" + brtypeid + "'");
        } 
    就错在这句话
    ("Add_Hysort.aspx?brtypeid='" + brtypeid + "'");去掉单引号就行了都加点分 呵呵