Use "int" or "Int32" while type casting?
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;
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.)
链接地址: http://www.djcxy.com/p/21040.html