Click or drag to resize

CnvNumToBytes Method

Convert a 32-bit integer to an array of 4 bytes.

Namespace: CryptoSysPKI
Assembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.30549 (23.1.0.0)
Syntax
public static byte[] NumToBytes(
	uint n,
	CnvEndianNess endn = CnvEndianNess.BigEndian
)

Parameters

n  UInt32
Integer to be converted
endn  CnvEndianNess  (Optional)
Byte order

Return Value

Byte
Byte array containing representation of integer in given order
Example
C#
byte[] bb = Cnv.NumToBytes(0xdeadbeef, Cnv.EndianNess.BigEndian);
Console.WriteLine(Cnv.ToHex(bb));  // DEADBEEF
byte[] bl = Cnv.NumToBytes(0xdeadbeef, Cnv.EndianNess.LittleEndian);
Console.WriteLine(Cnv.ToHex(bl));  // EFBEADDE
See Also