Different programming languages use different terms to identify the fundamental managed types. Class library designers must avoid using language-specific terminology. Follow the rules described in this section to avoid type name confusion.

Use names that describe a type's meaning rather than names that describe the type. In the rare case that a parameter has no semantic meaning beyond its type, use a generic name. For example, a class that supports writing a variety of data types into a stream might have the following methods.

void Write(double value);
void Write(float value);
void Write(long value);
void Write(int value);
void Write(short value);

Do not create language-specific method names, as in the following example.

void Write(double doubleValue);
void Write(float floatValue);
void Write(long longValue);
void Write(int intValue);
void Write(short shortValue);

In the extremely rare case that it is necessary to create a uniquely named method for each fundamental data type, use a universal type name. The following table lists fundamental data type names and their universal substitutions.

C# type name Universal type name
sbyte SByte
byte Byte
short Int16
ushort UInt16
int Int32
uint UInt32
long Int64
ulong UInt64
float Single
double Double
bool Boolean
cha Char
string String
object Object

Last edited Jul 15, 2010 at 2:03 PM by camalot, version 1