[IronPython] C#, Types and IronPython

Simon Dahlbacka simon.dahlbacka at gmail.com
Sun Mar 11 19:34:25 CET 2007


>
>
> Several of the MSDN examples use 'typeof(int)', why not just specify
> 'Int32' ? I guess it makes the code less platform dependent ?? Oh well.
>

they are not the same thing

In CLS (or whatever the .net type system is called), System.Int32 is the
"normal" integer type, that you can type just int in C# is just syntactic
sugar.

In normal cases you work with variables, but in some cases you want to work
with the types (just as you can use e.g. type(42) in python), in that case
you can use either typeof(int) or int foo=42;foo.GetType() (or Type.GetType
("System.Int32") ) and of these the former is more efficient if the type you
want is known at compile time..

hope this helps,

Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070311/a337a3f7/attachment.html>


More information about the Ironpython-users mailing list