프로그래밍/C#
C# int to hex(byte)
초징
2017. 6. 15. 17:11
반응형
256이 넘는 상수값을 헥사값으로 표현하기
1 2 | int tmep = 1310; byte[] intBytes = BitConverter.GetBytes(temp); | cs |
결과 : intByte[0] = 30 / intByte[1] = 5
5와 30(1E)를 합치면 51E가 되어 즉, 1310이 나오게 된다.
순서 주의하여 써야함!!
그냥 쓰고싶으면 Reverse를 이용하면 됨!(아래 참고)
1 2 3 4 | int intValue; byte[] intBytes = BitConverter.GetBytes(intValue); Array.Reverse(intBytes); byte[] result = intBytes; |
내 생각인데.. result는 딱히 없어도 될것 같다.. 충분히 intBytes에서 바뀌어있을거같은뎅
반응형