Built-in types - C# reference (original) (raw)

The following table lists the C# built-in value types:

C# type keyword .NET type
System.Boolean
byte System.Byte
sbyte System.SByte
System.Char
decimal System.Decimal
double System.Double
float System.Single
int System.Int32
uint System.UInt32
nint System.IntPtr
nuint System.UIntPtr
long System.Int64
ulong System.UInt64
short System.Int16
ushort System.UInt16

The following table lists the C# built-in reference types:

C# type keyword .NET type
object System.Object
string System.String
delegate System.Delegate
dynamic System.Object

In the preceding tables, the C# type keyword from the left column (except delegate and dynamic) is an alias for the corresponding .NET type. They're interchangeable. For example, the following declarations declare variables of the same type:

int a = 123;
System.Int32 b = 123;

The dynamic type is similar to object. The main differences are:

The delegate keyword declares a type derived from System.Delegate. System.Delegate type is an abstract type.

The keyword represents the absence of a type. You use it as the return type of a method that doesn't return a value.

The C# language includes specialized rules for the System.Span and System.ReadOnlySpan types. These types aren't classified as built-in types, because there aren't C# keywords that correspond to these types. The C# language defines implicit conversions from array types and the string type to Span<T> and ReadOnlySpan<T>. These conversions integrate Span types into more natural programming scenarios. The following conversions are defined as implicit span conversions:

The compiler never ignores any user defined conversion where an applicable implicit span conversion exists. Implicit span conversions can be applied to the first argument of extension methods, the parameter with the this modifier. Implicit span conversions aren't considered for method group conversions.

See also