RT这样的
我有一个ulong类型的变量a,这个a的说明是:
8个字节,从高到低依次为:年(实际年份-2000)、月、日、时、分、秒、毫秒(2字节)请问我要怎么才能取出这里面的年月、日、时、分、秒、毫秒 呢··c#

解决方案 »

  1.   

    ulong a = XXXXXXX;
    byte[] buffer = BitConverter.ToBytes(a);
    int year = BitConverter.ToShort(a, 0);
    int month = BitConverter.ToShort(a, 2);类似这样就好
      

  2.   

    byte[] buffer = BitConverter.ToBytes(a);//先将a转成字节数组
     int year = BitConverter.ToShort(a, 0);//然后取字节数据
     int month = BitConverter.ToShort(a, 2);
      

  3.   

    也可以用位运算。
    ulong somevalue;
    year = somevalue >> 56 + 2000;
    month = (somevalue >> 48) % 256;
    ...