今天研究C#调用API,需要把long类型拆分成LowPart和HighPart两部分,所以写了一个方法,来转换这两种类型。
1
using
System;
2
3
namespace
Skyfei
4
{ 5 public struct LargeInteger 6 { 7 Int32 _LowPart; 8 Int32 _HighPart; 9 public Int32 LowPart10 {11 get12 {13 return _LowPart;14 }15 set 16 {17 _LowPart = value;18 }19 }20 21 public Int32 HighPart22 {23 get24 {25 return _HighPart;26 }27 set 28 {29 _HighPart = value;30 }31 }32 }33 /**//// <summary>34 /// LargeInteger 的摘要说明。35 /// </summary>36 public class LInteger37 {38 39 public LInteger()40 {41 //42 // TODO: 在此处添加构造函数逻辑43 //44 }4546 public static long GetLongValue(LargeInteger largeInteger)47 { 48 return (long)(((ulong)largeInteger.HighPart << 32) + (uint)largeInteger.LowPart);49 }5051 public static LargeInteger GetLargeIntegerValue(long longNumber)52 { 53 LargeInteger t = new LargeInteger();54 t.LowPart = (Int32) longNumber;55 t.HighPart = (Int32) (longNumber >> 32);56 return t;57 }58 }59}
60
转载于:https://www.cnblogs.com/skyfei/archive/2005/07/05/186756.html