(C#) 数据类型转换. 填充下列函数体
// typedef struct
// {
// UINT16 day :5; // years since 1904 (MAC format)
// UINT16 month :4;
// UINT16 year :7;
// } DateType;
//
// Sample; byte[] = 0x90CA -> UInt16 = 0xCA90 -> 1100101 0100 10000 year = 101 month = 4 day =16
// year = 101 + 1904 = 2005 /// <summary>
/// DateType 转换成 代表year month day 的整形数组, 即是分离年,月,日字段
/// </summary>
/// <param name="byteDateType"></param>
/// <returns></returns>
public static int[] DateTypeToDate (byte[] byteDateType)
{
// 答案:
}
// typedef struct
// {
// UINT16 day :5; // years since 1904 (MAC format)
// UINT16 month :4;
// UINT16 year :7;
// } DateType;
//
// Sample; byte[] = 0x90CA -> UInt16 = 0xCA90 -> 1100101 0100 10000 year = 101 month = 4 day =16
// year = 101 + 1904 = 2005 /// <summary>
/// DateType 转换成 代表year month day 的整形数组, 即是分离年,月,日字段
/// </summary>
/// <param name="byteDateType"></param>
/// <returns></returns>
public static int[] DateTypeToDate (byte[] byteDateType)
{
// 答案:
}
解决方案 »
- 一个配置文件怎么读取
- 关于修改DataSet数据
- C#如何在 运行时生成的PictureBox中 显示图标文件(.ico) 快被搞死了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 如何在 aspx 页面下 添加 类似于 winform 下的 table control 控件?
- 请问一个自动关机的问题,问题简单,高分(在线等,问题解决立即给分)
- 各位老大,帮帮忙,可能是数据库连接的问题,花了几百分了,还没搞定呀。。帮顶的都有分
- 在CSDN网下了员工培训管理系统的C#代码!竟然看不懂里面的数据库
- 修改表格里的数据
- propertygrid (...)按钮问题
- 请问C#怎么调用DLL呀
- 在线打分!!!!窗体的启动??
- 有谁遇到过这么神奇的事?
typedef……
public static int[] DateTypeToDate (byte[] byteDateType)
{
if( byteDateType == null || byteDateType.Length != 2 ) return null;
const int YEAR_INDEX = 0;
const int MONTH_INDEX = 1;
const int DAY_INDEX = 2; string strDateBinValue = string.Format( "{0:00000000}{1:00000000}",
Convert.ToString( byteDateType[1], 2 ),
Convert.ToString( byteDateType[0], 2 ) ); int[] nDateArray = new int[3]{ 1904, 0, 0 };//Set default value
// Get year value
nDateArray[ YEAR_INDEX ] += Convert.ToInt32( strDateBinValue.Substring( 0,7 ), 2 ); // Get month value
nDateArray[ MONTH_INDEX ] = Convert.ToInt32( strDateBinValue.Substring( 7, 4 ), 2 ); // Get day value
nDateArray[ DAY_INDEX ] = Convert.ToInt32( strDateBinValue.Substring( 11 ), 2 );
return nDateArray;
}