■サフィックス(接尾語)
| C# | VB.NET | .NET型 | C# サフィックス | VB.NET サフィックス |
|---|---|---|---|---|
| sbyte | SByte | System.SByte | - | - |
| byte | Byte | System.Byte | - | - |
| short | Short | System.Int16 | - | S |
| ushort | UShort | System.UInt16 | - | US |
| int | Integer | System.Int32 | - | I |
| uint | UInteger | System.UInt32 | U or u | UI |
| long | Long | System.Int64 | L or l | L |
| ulong | ULong | System.UInt64 | UL or ul | UL |
| float | Single | System.Single | F or f | F |
| double | Double | System.Double | D or d | R |
| decimal | Decimal | System.Decimal | M or m | D |
| char | Char | System.Char | - | C |
| bool | Boolean | System.Boolean | - | - |
| string | String | System.String | - | - |
| DateTime | Date | System.DateTime | - | - |
| object | Object | System.Object | - | - |
以下は10進型の初期化例と、サフィックスとは関係ありませんが日付型の初期化例。
■C#
decimal dc = 1.111m;
DateTime dt = new DateTime(2011, 7, 28);■VB.NET
Dim dc As Decimal = 1.111D
Dim dt As Date = #7/28/2011#
'Dim dt As Date = New DateTime(2011, 7, 28) 'C#と同様にも書ける■環境
OS:Microsoft Windows XP Home Edition 日本語 Service Pack 3
IDE:Microsoft Visual Studio 2005 Standard Edition 日本語 Service Pack 1
Framework:Microsoft .NET Framework Version 2.0 SP2
■関連投稿
(C#, VB.NET)データ型