[IronPython] How to get System.Single[]?

Kevin Bjorke KBjorke at nvidia.com
Thu Jun 22 18:46:53 CEST 2006


Thanks, that's a real help too.

Might this issue eventually just disappear, since some CLR environments
(say, C#) are perfectly happy just passing arrays of native floats and
the ColorBlend class just does the right thing? Seems like a bit of a
minefield if some .NET methods randomly need Single while others are
okay with float. If it's a permanent condition, your tuple trick might
be good to include in the FAQ

kb 

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland
Sent: Thursday, June 22, 2006 8:38 AM
To: Discussion of IronPython
Subject: Re: [IronPython] How to get System.Single[]?

A slightly easier version is:

>>> System.Array[System.Single]( (1,2,3) )
System.Single[](1.0, 2.0, 3.0)

We make the System.Array class indexable by type and allow you to
quickly construct arrays w/ specific values that way.

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Kevin Bjorke
Sent: Thursday, June 22, 2006 5:16 AM
To: Discussion of IronPython
Subject: Re: [IronPython] How to get System.Single[]?

Yes, that's it,

a=System.Array.CreateInstance(System.Single, 3)

combined with System.Convert.ToSingle() and a.SetValue() to insert
values other than zero

Thanks!
KB

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Jonathan Jacobs
Sent: Thursday, June 22, 2006 3:28 AM
To: Discussion of IronPython
Subject: Re: [IronPython] How to get System.Single[]?

Kevin Bjorke wrote:
> I need to create a list of Singles to use
> System.Drawing.Darwing2D.ColorBlend's Position member. Color me
> ignorant, but how can I create such a thing? I can't just pass a list
of
> floats

It would be convenient to pass a tuple of floats, too bad this doesn't
work.
You can use System.Array.CreateInstance to create a Single[]:

 >>> System.Array.CreateInstance(System.Single, 3) System.Single[](0.0,
0.0, 0.0)

Hope this helps.
--
Jonathan

_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
------------------------------------------------------------------------
-----------
This email message is for the sole use of the intended recipient(s) and
may contain confidential information.  Any unauthorized review, use,
disclosure or distribution is prohibited.  If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies of the original message.
------------------------------------------------------------------------
-----------
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list