Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSIL of System.Int32 and int will be same? [duplicate]

Tags:

c#

.net

asp.net

Possible Duplicate:
C#, int or Int32? Should I care?

Please any one let me know MSIL of System.Int32 and int will be same or different, If different then which one we should use.

Edit:

this won't compile

public  enum MyEnum : Int32
{
    AEnum = 0
}

but this will

public enum MyEnum : int
{
    AEnum = 0
}
like image 432
Pankaj Agarwal Avatar asked May 31 '11 11:05

Pankaj Agarwal


1 Answers

int is an alias for System.Int32, they are completely the same.

enums only take integral types as type, as this would be possible otherwise:

using Int32 = System.String;

public enum Something : Int32
{
}

This is according to C# spec, which states

enum-declaration:
[attributes] [enum-modifiers ] enum identifier [enum-base] enum-body [;]

where
enum-base:
":" integral-type

With integral type specified as:

integral-type:
sbyte
byte
short
ushort
int
uint
long
ulong
char
like image 54
Femaref Avatar answered Oct 02 '22 08:10

Femaref