C# Convert Methods

Beginner
6 min read
Updated: Nov 2026
29 method guides
Method index

About This Index

This page is the C# Convert Methods index. Each row links to a full guide with syntax, parameters, return value, three examples, and FAQs.

Learn what Convert is for on /c-sharp/convert. Use this page when you need a specific API such as ToInt32(), ToString(), or ToBase64String().

Convert vs Parse.

Convert.ToInt32(null) returns 0 for many numeric overloads. int.Parse(null) throws. Bad text still throws FormatException; out-of-range values throw OverflowException. Prefer TryParse when input may be wrong.

How to Call a Convert Method

All of these helpers are static on Convert:

C#
int n = Convert.ToInt32("42");
string s = Convert.ToString(3.14);
bool ok = Convert.ToBoolean("True");
string b64 = Convert.ToBase64String(new byte[] { 1, 2, 3 });

C# Convert Methods Table

All method guides in this C# tutorial series (29 tutorials), grouped by purpose.

Type conversion

18 methods

Convert values between common CLR types—numbers, bool, char, DateTime, string—plus ChangeType, GetTypeCode, and IsDBNull.

MethodDescriptionTutorial
ToBoolean()Convert a value to bool—True/False text (case-insensitive) or non-zero numbers.Try it
ToByte()Convert a value to byte (0–255). Overflow and bad format throw.Try it
ToSByte()Convert a value to sbyte (−128…127).Try it
ToChar()Convert a value to a single Unicode char.Try it
ToInt16()Convert a value to short (Int16, −32768…32767).Try it
ToInt32()Convert a value to int (Int32)—the most common Convert call.Try it
ToInt64()Convert a value to long (Int64) for larger whole numbers.Try it
ToUInt16()Convert a value to ushort (0…65535).Try it
ToUInt32()Convert a value to uint (0…4294967295).Try it
ToUInt64()Convert a value to ulong for the largest unsigned whole numbers.Try it
ToSingle()Convert a value to float (Single)—32-bit floating point.Try it
ToDouble()Convert a value to double—64-bit floating-point numbers.Try it
ToDecimal()Convert a value to decimal—precise base-10 numbers for money and totals.Try it
ToDateTime()Convert a string or object to DateTime using culture rules.Try it
ToString()Convert a value to its string representation.Try it
ChangeType()Convert an IConvertible value to a Type or TypeCode at runtime.Try it
GetTypeCode()Return the TypeCode for a value or Type.Try it
IsDBNull()Test whether a value is database null (DBNull).Try it

Base64

7 methods

Encode bytes as Base64 text, decode Base64 back to bytes, and Try* helpers that avoid throwing on bad input.

MethodDescriptionTutorial
ToBase64String()Encode a byte array as a Base64 string.Try it
ToBase64CharArray()Encode bytes into a Base64 char[] buffer you provide.Try it
FromBase64String()Decode a Base64 string back into a byte array.Try it
FromBase64CharArray()Decode Base64 characters from a char[] slice into bytes.Try it
TryToBase64Chars()Try to encode bytes into a Base64 char span without throwing on small buffers.Try it
TryFromBase64String()Try to decode a Base64 string without throwing on bad input.Try it
TryFromBase64Chars()Try to decode Base64 characters from a span without throwing.Try it

Hex

4 methods

Encode and decode hexadecimal strings (.NET 5+ ToHexString/FromHexString; newer Try* overloads).

MethodDescriptionTutorial
ToHexString()Encode bytes as a hexadecimal string (.NET 5+).Try it
FromHexString()Decode a hex string into a byte array (.NET 5+).Try it
TryToHexString()Try to write hex characters into a destination span.Try it
TryFromHexString()Try to decode hex text into a byte span without throwing.Try it

Frequently Asked Questions

They are static helpers on System.Convert for changing values between types (ToInt32, ToString, ToBoolean), encoding Base64/hex, and helpers like ChangeType, GetTypeCode, and IsDBNull.
This index lists 29 guides: type conversion, Base64, and hex APIs.
Both read a number from a string. Convert.ToInt32(null) returns 0; int.Parse(null) throws. Prefer int.TryParse when input may be invalid.
Most Convert.To* methods throw FormatException or OverflowException. Try* Base64/hex helpers return false instead of throwing.
Read the C# Convert hub first. Then open ToInt32(), ToString(), ToBoolean(), and ToBase64String() from the tables below.

Start with ToInt32()

Turn text into a 32-bit integer—the Convert call beginners use most often.

ToInt32() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful