C# Types and the CLS Compliant types

January 15, 2011

This post of mine is to give a quick run on the types available in C# and to list those which are CLS(Common Language Specification) compliant on the .NET framework.

As we all know the data types supported under C# are,

Signed Byte – System.SByte
Unsigned Byte – System.Byte

Signed short integer – System.Int16
Unsigned short integer – System.UInt16

Signed integer – System.Int32
Unsigned integer – System.UInt32

Signed Long integer – Syste.Int64
Unsigned Long integer – System.UInt64

Character – System.Char

Which are CLS compliant?
Amongst all these only few are CLS compliant, as defined to be used in a way that can be made to support the .NET’s feature of portability and inter language integration.

In the above set of types, we have the following only to be defined as CTS or CLS compliant to make it inter operable between different coding languages,

Unsigned Byte – System.Byte

Signed short integer – System.Int16

Signed integer – System.Int32

Signed Long integer – System.Int64

Character – System.Char

How do we get to define signed and Unsigned??

If you are likely to define an Unsigned value integer,

uint i = 24U; //this says that the i=24 and is Unsigned

int j = 22U; //this gives a compile time error as we can see ‘i’ is not an Unsigned


boolean b = true; // booleans can be true or false

So we use U, for unsigned, what about the others?

So here we go the other value types,

Long –> L
Unsigned –> U
Unsigned Long –> UL or LU

Float: F
Double: D
Decimal: M

Note: ‘Null’ is a reference type, whereas the above mentioned are value types


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: