KFDtool/sw/control/KFDtool.Shared/Utility.cs

33 lines
816 B
C#
Raw Normal View History

2019-07-29 15:24:10 -06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KFDtool.Shared
{
public class Utility
{
public static List<byte> ByteStringToByteList(string hex)
{
int NumberChars = hex.Length;
List<byte> bytes = new List<byte>();
for (int i = 0; i < NumberChars; i += 2)
{
bytes.Add(Convert.ToByte(hex.Substring(i, 2), 16));
}
return bytes;
}
2019-08-25 17:08:08 -06:00
public static string DataFormat(byte b)
{
return string.Format("{0:X2}", b);
}
public static string DataFormat(List<byte> b)
{
return BitConverter.ToString(b.ToArray());
}
2019-07-29 15:24:10 -06:00
}
}