拆分Int64/long 到HighPart/LowPart类型

今天研究C#调用API,需要把long类型拆分成LowPart和HighPart两部分,所以写了一个方法,来转换这两种类型。

 1using System;
 2
 3namespace Skyfei
 4{
 5    public struct LargeInteger
 6    {
 7        Int32 _LowPart;
 8        Int32 _HighPart;
 9        public Int32 LowPart
10        {
11            get
12            {
13                return _LowPart;
14            }

15            set 
16            {
17                _LowPart = value;
18            }

19        }

20    
21        public Int32 HighPart
22        {
23            get
24            {
25                return _HighPart;
26            }

27            set 
28            {
29                _HighPart = value;
30            }

31        }

32    }

33    /// <summary>
34    /// LargeInteger 的摘要说明。
35    /// </summary>

36    public class LInteger
37    {
38        
39        public LInteger()
40        {
41            //
42            // TODO: 在此处添加构造函数逻辑
43            //
44        }

45
46        public static long GetLongValue(LargeInteger largeInteger)
47        {            
48            return (long)(((ulong)largeInteger.HighPart << 32+ (uint)largeInteger.LowPart);
49        }

50
51        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/p/186756.html