it innovations GmbH
Kontaktinformation:

CSharp – Typen – Integrierte Typen

C# – Integrierte Werttypen

Schlüsselwort.NET-TypGrößeBeschreibungSuffix
boolSystem.Boolean1 Bitwahr oder falsch Wert
byteSystem.Byte8 BitNummerisch 0 bis 255
sbyteSystem.SByte8 BitNummerisch -128 bis 127
charSystem.Char2 Byteseinzelnes Zeichen/Buchstaben, umgeben von einfachen Anführungszeichen
decimalSystem.Decimal16 BytesBruchzahlen 28 bis 29 Dezimalstellen (128bit)m
doubleSystem.Double8 BytesBruchzahlen bis 15 Dezimalstellen (64bit)d
floatSystem.Single4 BytesBruchzahlen 6 bis 7 Dezimalstellen (32bit)f
intSystem.Int324 BytesGanzzahlen von -2.147.483.648 bis 2.147.483.647
uintSystem.UInt324 BytesGanzzahlen von 0 bis 4294967295u
nintSystem.IntPtr
longSystem.Int648 BytesGanzzahlen von -9.223.372.036.854.775.808 bis 9.223.372.036.854.775.807l
ulongSystem.UInt648 BytesGanzzahlen von 0 bis 18.446.744.073.709.551.615ul
shortSystem.Int16Ganzzahlen von -32.768 bis 32.767
ushortSystem.UInt16Ganzzahlen von 0 bis 65535

C# – Integrierte Verweistypen

Schlüsselwort.NET-Typ
objectSystem.Object
stringSystem.String
dynamicSystem.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;