1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Globalization;
- using System.Text;
- namespace Dfs.WayneChina.HengshanPayTerminal
- {
- public static class HengshanExtensions
- {
-
-
-
-
-
-
- public static int ToInt32(this byte[] source)
- {
- var hexTarget = new StringBuilder(source.Length * 2);
- foreach (byte b in source)
- hexTarget.AppendFormat("{0:x2}", b);
- return int.Parse(hexTarget.ToString(), NumberStyles.HexNumber);
- }
-
-
-
-
-
- public static ushort ToUInt16(this char[] source)
- {
- var hexTarget = new StringBuilder(source.Length * 2);
- foreach (byte b in source)
- hexTarget.AppendFormat("{0:x2}", b);
- return UInt16.Parse(hexTarget.ToString(), NumberStyles.HexNumber);
- }
- public static byte ToByte(this string source)
- {
- return Convert.ToByte(Int16.Parse(source, NumberStyles.HexNumber));
- }
- public static ushort ToUInt16(this string source)
- {
- return UInt16.Parse(source, NumberStyles.HexNumber);
- }
- public static uint ToUInt32(this string source)
- {
- return UInt32.Parse(source, NumberStyles.HexNumber);
- }
- }
- }
|