Training
Module
Choose the correct data type in your C# code - Training
Choose the correct data type for your code from several basic types used in C#.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This table lists the base data types that are supported by the Windows Runtime, and indicates the corresponding type in C#, Visual Basic, and C++.
Data type | JavaScript | C# | VB | C++ |
---|---|---|---|---|
Boolean | Boolean | bool | Boolean | bool |
Byte | Number | byte | Byte | unsigned char |
Char | String | char | Char | unsigned char |
Char16 | String | char | Char | wchar_t |
DateTime | Date | DateTimeOffset | DateTimeOffset | DateTime |
Double | Number | double | Double | double |
Guid | String | Guid | Guid | Guid |
Int16 | Number | short | Short | short |
Int32 | Number | int | Integer | int |
Int64 | Number | long | Long | __int64 |
Object | Object | object | Object | Object^ |
Point | Point | Point | Point | Point |
Rect | Rect | Rect | Rect | Rect |
Single | Number | float | Single | float |
Size | Size | Size | Size | Size |
String | String | string | String | String^ |
TimeSpan | Number | TimeSpan | TimeSpan | TimeSpan |
UInt8 | Number | byte | Byte | unsigned char |
UInt16 | Number | ushort | UShort | unsigned short |
UInt32 | Number | uint | UInteger | unsigned int |
UInt64 | Number | ulong | ULong | unsigned __int64 |
Uri | Uri | Uri | Uri | Uri^ |
Void | Undefined | void | Void | void |
The following table indicates the .NET types that correspond to the Windows Runtime data types.
Windows Runtime | .NET |
---|---|
Boolean | System.Boolean |
Byte | System.Byte |
Char | System.Char |
Char16 | System.Char |
DateTime | System.DateTimeOffset |
Double | System.Double |
Guid | System.Guid |
Int16 | System.Int16 |
Int32 | System.Int32 |
Int64 | System.Int64 |
Object | System.Object |
Single | System.Single |
String | System.String |
TimeSpan | System.TimeSpan |
UInt8 | System.Byte |
UInt16 | System.UInt16 |
UInt32 | System.UInt32 |
UInt64 | System.UInt64 |
Uri | System.Uri |
Void | System.Void |
Training
Module
Choose the correct data type in your C# code - Training
Choose the correct data type for your code from several basic types used in C#.