CryptoSys PKI Pro Manual

Cnv.NumFromBytes Method

Convert the leftmost four bytes of an array to an unsigned 32-bit integer.

Syntax

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

Parameters

b  Byte
Byte array to be converted
endn  Cnv.EndianNess  (Optional)
Byte order

Return Value

Integer value

Remarks

An array shorter than 4 bytes will be padded on the right with zeros

Example

byte[] b = new byte[4] { 0xde, 0xad, 0xbe, 0xef };
uint nb = Cnv.NumFromBytes(b, Cnv.EndianNess.BigEndian);
Console.WriteLine("0x" + nb.ToString("x8"));  // 0xdeadbeef
uint nl = Cnv.NumFromBytes(b, Cnv.EndianNess.LittleEndian);
Console.WriteLine("0x" + nl.ToString("x8"));  // 0xefbeadde

See Also

VB6/C equivalent: CNV_NumFromBytes

[Contents] [Index]

[PREV: Cnv.HexFromBase64 Method...]   [Contents]   [Index]   
   [NEXT: Cnv.NumToBytes Method...]

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