“struct”和“value struct”之间的区别(Difference between “struct” and “value struct”)
有什么区别
public struct X{ public: int A;};和
public value struct X{ public: int A;};如何将一个转换为另一个?
What is the difference between
public struct X{ public: int A;};and
public value struct X{ public: int A;};How can I convert one into the other?
最满意答案
第一个是普通的C ++结构。
使用value struct创建C ++ / CLI值类型(.NET结构)。 您通常希望手动从一个副本复制到另一个,但如果内存布局相同,您通常可以使用Marshal::PtrToStructure类的东西直接复制数据。 请注意,这会返回一个盒装value struct ,但是,手动复制通常更有效。
The first is a normal C++ structure.
Using value struct creates a C++/CLI value type (a .NET structure). You typically will want to copy from one to the other manually, though if the memory layout is the same, you can often use things like Marshal::PtrToStructure to copy the data directly. Note that this returns a boxed value struct, however, so manual copying is often more efficient.
更多推荐
发布评论