C# Data Types

C# Data Types

27/04/2020 0 By Admin

C# is a strongly typed language.  All variables and constants must be assigned as a particular data type. The type establishes how much memory is reserved for the variable or constant.

Integral Data Types

Integral data types represent whole numbers.  They do not have decimal notation.

C# TypeNumeric Type.Net alias TypeNumeric RangeBits
byteIntegralSystem.Byte0 to 2558
sbyteIntegralSystem.SByte128 to 1278
charIntegralSystem.CharU+0000 to U + ffff16
decimalDecimalSystem.Decimal-2,147,483,648 to 2,147,483,647128
doubleFloating-pointSystem.Double(+/-)5.0 x 10-324 to (+/-)1.7 x 1030864
floatFloating-pointSystem.Single-3.4 x 1038 to + 3.4 x 103832
intIntegralSystem.Int32-2,147,483,648 to 2,147,483,64732
uintIntegralSystem.Uint320 to 4,294,967,29532
longIntegralSystem.Int64-9,223,372,036,854,775,808 to 9,223,372,036,854,775,80764
ulongIntegralSystem.UInt640 to 18,446,744,073,709,551,61564
shortIntegralSystem.Int16-32,768 to 32,76716
uShortIntegralSyste.UInt160 to 65,53516

Range and Precision

Selection of which data type to use will depend on the numeric range of the variable and sometimes the precision required. A decimal, for example is often used in finance.