Files
V2GProtocol_CSharp/Helper.cs
chiDT 7ba42fe215 Refactor helper functions to separate Helper class and translate comments to Korean
- Extract hex conversion functions to new Helper.cs file
- Remove duplicate helper functions from Program.cs and V2GDecoder.cs
- Update all references to use Helper class
- Translate all comments in Program.cs to Korean
- Improve code organization and reusability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-07 20:08:45 +09:00

38 lines
1.2 KiB
C#

using System;
namespace V2GProtocol
{
/// <summary>
/// 헥스 문자열 변환 헬퍼 클래스
/// </summary>
public static class Helper
{
/// <summary>
/// 헥스 문자열을 바이트 배열로 변환
/// </summary>
/// <param name="hexString">헥스 문자열</param>
/// <returns>바이트 배열</returns>
public static byte[] FromHexString(string hexString)
{
if (hexString.Length % 2 != 0)
throw new ArgumentException("Invalid hex string length");
byte[] bytes = new byte[hexString.Length / 2];
for (int i = 0; i < bytes.Length; i++)
{
bytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
}
return bytes;
}
/// <summary>
/// 바이트 배열을 헥스 문자열로 변환
/// </summary>
/// <param name="bytes">바이트 배열</param>
/// <returns>헥스 문자열</returns>
public static string ToHexString(byte[] bytes)
{
return BitConverter.ToString(bytes).Replace("-", "");
}
}
}