C# – Integrierte Werttypen
Schlüsselwort | .NET-Typ | Größe | Beschreibung | Suffix |
---|---|---|---|---|
bool | System.Boolean | 1 Bit | wahr oder falsch Wert | |
byte | System.Byte | 8 Bit | Nummerisch 0 bis 255 | |
sbyte | System.SByte | 8 Bit | Nummerisch -128 bis 127 | |
char | System.Char | 2 Bytes | einzelnes Zeichen/Buchstaben, umgeben von einfachen Anführungszeichen | |
decimal | System.Decimal | 16 Bytes | Bruchzahlen 28 bis 29 Dezimalstellen (128bit) | m |
double | System.Double | 8 Bytes | Bruchzahlen bis 15 Dezimalstellen (64bit) | d |
float | System.Single | 4 Bytes | Bruchzahlen 6 bis 7 Dezimalstellen (32bit) | f |
int | System.Int32 | 4 Bytes | Ganzzahlen von -2.147.483.648 bis 2.147.483.647 | |
uint | System.UInt32 | 4 Bytes | Ganzzahlen von 0 bis 4294967295 | u |
nint | System.IntPtr | |||
long | System.Int64 | 8 Bytes | Ganzzahlen von -9.223.372.036.854.775.808 bis 9.223.372.036.854.775.807 | l |
ulong | System.UInt64 | 8 Bytes | Ganzzahlen von 0 bis 18.446.744.073.709.551.615 | ul |
short | System.Int16 | Ganzzahlen von -32.768 bis 32.767 | ||
ushort | System.UInt16 | Ganzzahlen von 0 bis 65535 |
C# – Integrierte Verweistypen
Schlüsselwort | .NET-Typ |
---|---|
object | System.Object |
string | System.String |
dynamic | System.Object |
Jedes Schlüsselwort (außer dynamic) ist ein Alias für den entsprechenden .NET Typ. Sie sind austauschbar.
int a = 123;
System.Int32 b = 123;
Das Schlüsselwort void steht für das Fehlen eines Typs. Sie verwenden es als Rückgabetyp einer Methode, die keinen Wert zurückgibt.
uint ui = 112u;
long l = -21755458887772l;
ulong ul = 21755458887772ul;
float fl = 15.31f;
double d = 10783377.467d;
decimal dec = 2345.23m;