A为下列类型时可以实现(Double)A:
Byte,Sbyte,Int16,UInt16,Char,Int32,UInt32,Single;A为下列类型时,(Double)A可能会导致丢失精度:
Int64,Uint64,Decimal

解决方案 »

  1.   

    DateTime 是结构而Double是类阿.(Double)A 是一个拆箱的过程....
      

  2.   

    struct Pig
    {
    string NikeName;
    int Weight;
    } class Person
    {
    public string Name;
    public Person()
    {
    Name = "Name";
    }
    }
    class Man :Person
    {
    public string Job;
    public int Salary;
    public Man()
    {
    Job = "Job";
    Salary = 10000;
    }
    } class Child : Person
    {
    public string Toy;
    public Child()
    {
    Toy = "Toy";
    }
    static void Main()
    {
    Child c = new Child(); // child 的指针 Person p = c; //所谓装箱,
    Child c2 = (Child)p; //必须本身是Child的指针,否则由于数据结构不同,就会出错. string sToy = ((Child)p).Toy;//拆箱,没有问题,本事是Child的指针 Man m = (Man)p; //错误的拆箱,强制转化,编译没问题,但运行时报错,因为数据结构和虚函数指针等不同,如果按Man类访问要出错误 string sJob = ((Man)p).Job; //错误的拆箱,编译没问题,但运行时报错,因为它指向的对象是child

    //Pig pig = (Pig)p; 没有关系,你叫他怎么转化? }
    }
      

  3.   

    to  gujianxin:
    能說的詳細點