Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将C类对象传递给C++非托管代码?_C#_C++_.net_Marshalling - Fatal编程技术网

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

我有一个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 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;
  }
你可以找到答案。