Ironpython and other hosting languages use constructor value assignment for the value type. Otherwise, the value cannot be assigned.

Source: Internet
Author: User

I cannot assign a value to a struct using ironpython.

 
[Serializable] public struct matrix3x3 {public double XX; // public double XY; // public double xz; // public double Yx; // public double YY; // public double YZ; // public double ZX; // public double ZY; // public double ZZ; Public override string tostring ();}

Element1 = matrix3x3 () element1.xx = x. X element1.xy = x.y element1.xz = x. Z element1.yx = y. X element1.yy = y.y element1.yz = y.z element1.zx = z. X element1.zy = z. Y element1.zz = z. Z theui. nxmessagebox. show ("error", nxmessagebox. dialogtype. warning, X. x. tostring () theui. nxmessagebox. show ("error", nxmessagebox. dialogtype. warning, element1.xx. tostring () theui. nxmessagebox. show ("error", nxmessagebox. dialogtype. warning, STR (type (X. x) theui. nxmessagebox. show ("error", nxmessagebox. dialogtype. warning, STR (type (element1.xx )))

X. x. tostring () is a real number, but element1.xx. tostring () is always 0
Both types are <float>

I spent the whole morning and afternoon working on it. How many days can my life be !!!
Finally, a similar post was posted on stackoverflow:
Http://stackoverflow.com/questions/2664381/how-to-handle-value-types-when-embedding-ironpython-in-c

Just change it to the following:

 
Element1 = matrix3x3 (xx = x. x, xy = x.y, xz = x. z, YX = y. x, YY = y.y, YZ = y.z, zx = z. x, ZY = z. y, ZZ = z. z)

Originally, the property of the value type must be assigned in the constructor; otherwise, a copy is obtained !!!!

It's too unreasonable!

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.