[IronPython] C#, Types and IronPython
Nicholas Riley
njriley at uiuc.edu
Sun Mar 11 15:56:32 CET 2007
On Sun, Mar 11, 2007 at 02:27:11PM +0000, Michael Foord wrote:
> What object does 'typeof(int)' (in C# *not* IronPython) return. I guess
> it is not System.Int32 !
Indeed it is; I'm not sure why you're confused about this when a
one-line C# program will give you the answer :-) typeof(int) is
converted by the C# compiler into the following IL:
ldtoken [mscorlib]System.Int32
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
which makes it pretty clear that System.Int32 is specified at compile
time.
> Is there a common base class for the C# number types ?
No; however there are several common interfaces these types implement,
such as IConvertible.
--
Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
More information about the Ironpython-users
mailing list