CSharp examples for System:Byte
Returns the specified 32-bit signed integer value as an array of Binary Coded Decimal format bytes.
using System;/*from ww w . j a v a 2 s . c om*/ public class Main{ /// <summary> /// Returns the specified 32-bit signed integer value as an array of Binary Coded Decimal format bytes. /// </summary> /// <param name="input">32-bit signed integer to convert.</param> /// <param name="size">Desired size of returned array.</param> public static byte[] Int32ToBCD(int input, int size) { byte[] result = new byte[size]; for (int i = 0; i < size; i++) { int p = input%100; input /= 100; result[size - i - 1] = (byte)(p/10 << 4 | p%10); } return result; } }