common/Utils/ByteArrayStyle/ByteStyler.cs
2026-04-23 17:50:07 +02:00

40 lines
926 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ByteArrayStyle
{
public static class ByteStyler
{
public static Byte[] Parse(string inputValue, bool reverse )
{
Byte[] array = null;
try
{
String[] arr = inputValue.Trim().Split('-');
array = new Byte[arr.Length];
for (Int32 i = arr.Length - 1; i >= 0; i--) array[i] = Convert.ToByte(arr[i], 16);
if (reverse)
{
array = array.Reverse().ToArray();
}
}
catch (Exception ex)
{
throw ex;
}
return array;
}
public static string ToString(byte[] v)
{
return BitConverter.ToString(v);
}
}
}