Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use "int" or "Int32" while type casting? [duplicate]

Tags:

c#

c#-4.0

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

I'm using GetPosition(this) when MouseMoved event gets triggered so having:

Point pt = e.GetPosition(this);

As far as I see both following type casts work but which one is recommended and why?

int x = (int)pt.X;
int x = (Int32)pt.X;
like image 949
amit kohan Avatar asked Jun 05 '26 08:06

amit kohan


1 Answers

They do exactly the same thing - they'll even compile to the same IL. (Assuming you haven't got some crazy other Int32 type somewhere...)

int is just an alias for global::System.Int32.

(This doesn't just apply to casting - it's almost anywhere that a type name is used.)

like image 130
Jon Skeet Avatar answered Jun 07 '26 22:06

Jon Skeet