C# 如何将C类对象传递给C++非托管代码?
我有一个c代码中的对象,定义如下:C# 如何将C类对象传递给C++非托管代码?,c#,c++,.net,marshalling,C#,C++,.net,Marshalling,我有一个c代码中的对象,定义如下: class CSObject { int length; int width; IList<SubItem> Items; bool OnSale; ItemType type; //ItemType is an enum } Class SubItem { object AssociatedValue; List< Range > Highlight; // Range is anoth
class CSObject
{
int length;
int width;
IList<SubItem> Items;
bool OnSale;
ItemType type; //ItemType is an enum
}
Class SubItem
{
object AssociatedValue;
List< Range > Highlight; // Range is another class represents a pair (0, 4)
string Name;
IList<SubItem> Items;
string Title;
}
现在我们如何将它传递给C++代码中的方法? 我需要在C++侧创建类似的类并发送数据并在那里进行德语化吗? 我不需要修改C++侧的对象,只需要在它上面走就可以了。
我不知道这对你有什么帮助,但我很久以前就用过类似的东西
public struct AccountInfo
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public byte[] ExpirationDate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)]
public string CustomerId;
}
你可以找到答案。