C# Convert hex string to byte array

Programming/C# 2013. 9. 26. 18:05 Posted by 생각하는로뎅
반응형
  1. // string hax를 byte array로 변환  
  2. private static byte[] StringToByteArray(string hex)  
  3. {  
  4.     return Enumerable.Range(0, hex.Length)  
  5.                      .Where(x => x % 2 == 0)  
  6.                      .Select(x => Convert.ToByte(hex.Substring(x, 2), 16))  
  7.                      .ToArray();  
  8. }  
반응형

'Programming > C#' 카테고리의 다른 글

c# print byte array  (0) 2013.10.04
C# byte array to Array.ConvertAll:  (0) 2013.10.03
C# Save byte[] into a SQL Server database  (0) 2013.09.26
C# SqlDataReade  (0) 2013.09.25
C# write text file  (0) 2013.09.25