Different languages use different terms to identify the fundamental managed types. Designers must take care to avoid language-specific terminology. This section describes a set of rules that help avoid type name confusion.
void Write(double value); void Write(float value); void Write(long value); void Write(int value); void Write(short value);
rather than a language-specific alternative such as:
void Write(double doubleValue); void Write(float floatValue); void Write(long longValue); void Write(int intValue); void Write(short shortValue);
C# type name | VB type name | VC type name | IL representation | Universal type name |
---|---|---|---|---|
sbyte | NA | char | I1 | SByte |
byte | Byte | unsigned char | U1 | Byte |
short | Integer | short | I2 | Int16 |
ushort | NA | unsigned short | U2 | UInt16 |
int | Long | int | I4 | Int32 |
NA | unsigned int | U4 | Uint32 | |
long | LongLong | __int64 | I8 | Int64 |
ulong | NA | Unsigned __int64 | U8 | UInt64 |
float | Single | float | R4 | Single |
double | Double | double | R8 | Double |
bool | Boolean | bool | I4 | Boolean |
char | Char | wchar_t | U2 | Char |
string | String | String | System.String | String |
object | Object | Object | System.Object | Object |
E.g., a class that supports reading a variety of data types from a stream might have:
double ReadDouble(); float ReadSingle(); long ReadIn64(); int ReadInt32(); short ReadInt16();
rather than a language-specific alternative such as:
double ReadDouble(); float ReadFloat(); long ReadLong(); int ReadInt(); short ReadShort();