In C#, Convert.ToUInt32 returns a uint—unsigned 32-bit integer from 0 to 4,294,967,295.
Use it for sizes and IDs that never go negative. Negatives throw OverflowException.
This is a static member of System.Convert. You call it with the type name, such as Convert.ToUInt32(...). Convert is the everyday API for converting between common CLR types in C#.
Syntax
Convert text or numbers into a uint.
C#
uint a = Convert.ToUInt32("4000000000");
uint b = Convert.ToUInt32(20);
uint c = Convert.ToUInt32("FF", 16);
Call
What it does
Convert.ToUInt32("4000000000")
Large unsigned decimal string.
Convert.ToUInt32("FF", 16)
Hex with base 16.
null → 0. Prefer uint.TryParse for untrusted text.
Library declarations
C#
public static uint ToUInt32(string? value);
public static uint ToUInt32(string? value, int fromBase);
public static uint ToUInt32(int value);
Parameters
Parameter
Description
value
Required. Text or number to convert.
fromBase
Optional. 2, 8, 10, or 16.
Return Value
Return Value
Description
uint
Unsigned 32-bit result.
C# Examples
Example 1 — Bigger Than Int32
Parse an unsigned value above signed int max.
C#
using System;
class Program {
static void Main() {
uint n = Convert.ToUInt32("3000000000");
Console.WriteLine(n);
Console.WriteLine(n + 1);
}
}
Output
3000000000
3000000001
How It Works
3 billion. Above signed Int32 max.
uint fits. Unsigned 32-bit can hold it.
Increment. Shows normal arithmetic.
No negatives. This type starts at zero.
Example 2 — Hex to UInt32
Parse a hex string into uint.
C#
using System;
class Program {
static void Main() {
uint n = Convert.ToUInt32("A0", 16);
Console.WriteLine(n);
Console.WriteLine(Convert.ToUInt32("1010", 2));
}
}
Output
160
10
How It Works
A0 hex. Equals decimal 160.
Binary 1010. Equals 10.
fromBase. Chooses the digit system.
Same API family. Matches other Convert base overloads.
Example 3 — Catch Negative Input
Demonstrate overflow on −1.
C#
using System;
class Program {
static void Main() {
try {
Console.WriteLine(Convert.ToUInt32(-1));
} catch (OverflowException) {
Console.WriteLine("no negatives");
}
Console.WriteLine(Convert.ToUInt32(1));
}
}