CryptoSys PKI Pro Manual

Cnv.NumToBytes Method

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

Syntax

[C#]
public static byte[] NumToBytes(
   uint n,
   Cnv.EndianNess endn = Cnv.EndianNess.BigEndian 
)
[VB]
Public Shared Function NumToBytes (
   n As UInteger,
   Optional endn As Cnv.EndianNess = Cnv.EndianNess.BigEndian 
) As Byte()

Parameters

n  UInt32
Integer to be converted
endn  Cnv.EndianNess  (Optional)
Byte order

Return Value

Byte array containing representation of integer in given order

Example

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

VB6/C equivalent: CNV_NumToBytes

[Contents] [Index]

[PREV: Cnv.NumFromBytes Method...]   [Contents]   [Index]   
   [NEXT: Cnv.ReverseBytes Method...]

Copyright © 2004-26 D.I. Management Services Pty Ltd t/a CryptoSys. All rights reserved. Generated 2026-09-17T11:18:15Z.