Wow, I tried so many different variants, but this I must have missed! Thanks, it works!
2013/1/24 Tribble, Brett <btrib...@ea.com> > I don’t think the python.net clr module supports most of the methods etc. > that the IronPython one does:**** > > ** ** > > http://nullege.com/codes/search/clr**** > > ** ** > > Can you use the following instead?**** > > ** ** > > import System**** > > …**** > > ** ** > > …**** > > array = Array.CreateInstance(System.Int32, rows, columns)**** > > ** ** > > *From:* PythonDotNet [mailto:pythondotnet-bounces+btribble= > ea....@python.org] *On Behalf Of *Daniel Krause > *Sent:* Thursday, January 24, 2013 12:11 PM > *To:* pythondotnet@python.org > *Subject:* [Python.NET] How to pass a Type to a method?**** > > ** ** > > I would like to use System.Array.**** > > ** ** > > The following code is running with iron python**** > > ** ** > > import clr**** > > import System**** > > from System import Array**** > > from System import Int32**** > > from clr import GetClrType**** > > rows = 1**** > > columns = 2**** > > #method: Array.CreateInstance(Type, Int32, Int32)**** > > array = Array.CreateInstance(GetClrType(Int32), rows, columns)**** > > print array.GetLength(0)**** > > print array.GetLength(1)**** > > ** ** > > ouptput:**** > > 1**** > > 2**** > > ** ** > > The same code throws an import error in python for .NET**** > > from clr import GetClrType**** > > ImportError: cannot import name GetClrType**** > > ** ** > > Is another syntax for python for .Net necessary?**** > > Or is there perhaps another method to pass a Type to a method?**** >
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet