在sqlserver中的字段‘jffp’是bigint,数据是12位的数字,上次我问过一次转换的问题现在还是不行,请指点。
int i = Convert.ToIn64(ds.Tables[0].Rows[0]["jffp"]);
为什么会提示无法将long隐式转换成int呢?

解决方案 »

  1.   

    int i = (int) ds.Tables[0].Rows[0]["jffp"];
      

  2.   

    int i = (int) ds.Tables[0].Rows[0]["jffp"];
    请问这个和Convert有什么不同之处?新学习的很多问题都不懂
      

  3.   

    short i = Convert.ToIn16(ds.Tables[0].Rows[0]["jffp"]);int i = Convert.ToIn32(ds.Tables[0].Rows[0]["jffp"]);long i = Convert.ToIn64(ds.Tables[0].Rows[0]["jffp"]);LZ明白了吗?
      

  4.   

    隐性转换是低精度类型向高精度类型转换,如int-int64, float-double,可由系统自动进行,反之是显式转换,要手动写
    int i = (int) ds.Tables[0].Rows[0]["jffp"];
    这个与convert没啥不同
      

  5.   

    //为什么会提示无法将long隐式转换成int呢?
    你把long型值赋给int型变量i,当然要隐式转换
    但隐式转换只能小变大,不能大变小~