Home > Net >  How to transfer structure array in C #?
How to transfer structure array in C #?

Time:10-13

Struct A
{
Int a;
Int b;
XXX c;
}
C + + interface: void (A [] A) XXX
Corresponding to the void in the c # XXX (ref A)
How should the parameters into the?

CodePudding user response:

C + + interface is suppliers, cannot be changed, a layer of too much trouble to encapsulation in c + + (there are hundreds of functions)

CodePudding user response:

Written in c # and c is the same, just pass the array to add a c parameter specifies an array of size
The key is to complete the corresponding c and c # structure, such as byte alignment, data size, and so on

CodePudding user response:

Give you a reference structure, defined the length of the string type with respect to ok.
Also can agree on the length of the byte array.

 


///& lt; Summary>
///investors
///& lt;/summary>
[StructLayout (LayoutKind. Sequential)]
Public struct CThostFtdcInvestorField
{
///& lt; Summary>
///investors code
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=13)]
Public string InvestorID;
///& lt; Summary>
///brokerage company code
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=11)]
Public string BrokerID;
///& lt; Summary>
///investor group code
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=13)]
Public string InvestorGroupID;
///& lt; Summary>
///investors name
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=81)]
Public string InvestorName;
///& lt; Summary>
///certificate type
///& lt;/summary>
Public TThostFtdcIdCardTypeType IdentifiedCardType;
///& lt; Summary>
///id number
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr SizeConst=51)]
Public string IdentifiedCardNo;
///& lt; Summary>
///whether active
///& lt;/summary>
Public int IsActive.
///& lt; Summary>
///phone number
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=41)]
Public string Telephone;
///& lt; Summary>
///address
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=101)]
Public string Address;
///& lt; Summary>
///opening date
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=9)]
Public string OpenDate;
///& lt; Summary>
///phone
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=41)]
Public string Mobile;
///& lt; Summary>
///procedure template code rate
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=13)]
Public string CommModelID;
///& lt; Summary>
///deposit rate template code
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=13)]
Public string MarginModelID;
}

CodePudding user response:

If, written in c + +, c # call consider 32-bit 64 calls in different ways, I haven't heard of c + + write a, c # write a XXX () corresponding to what the devil

CodePudding user response:

Define a and c + + equivalent structures AA,
 
AA AA=[],,,
XXX (ref aa);



Other, can search: c # call c + + function

CodePudding user response:

reference 4 floor jx315425246 response:
if, written in c + +, c # call consider 32-bit 64 calls in different ways, I haven't heard of c + + write a, c # write a XXX () corresponding to what the devil



reference yahle reply: 3/f
give you a reference structure, defined the length of the string type with respect to ok.
Also can agree on the length of the byte array.

 


///& lt; Summary>
///investors
///& lt;/summary>
[StructLayout (LayoutKind. Sequential)]
Public struct CThostFtdcInvestorField
{
///& lt; Summary>
///investors code
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=13)]
Public string InvestorID;
///& lt; Summary>
///brokerage company code
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=11)]
Public string BrokerID;
///& lt; Summary>
///investor group code
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=13)]
Public string InvestorGroupID;
///& lt; Summary>
///investors name
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=81)]
Public string InvestorName;
///& lt; Summary>
///certificate type
///& lt;/summary>
Public TThostFtdcIdCardTypeType IdentifiedCardType;
///& lt; Summary>
///id number
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr SizeConst=51)]
Public string IdentifiedCardNo;
///& lt; Summary>
///whether active
///& lt;/summary>
Public int IsActive.
///& lt; Summary>
///phone number
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=41)]
Public string Telephone;
///& lt; Summary>
///address
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=101)]
Public string Address;
///& lt; Summary>
///opening date
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=9)]
Public string OpenDate;
///& lt; Summary>
///phone
///& lt;/summary>
[MarshalAs (UnmanagedType ByValTStr, SizeConst=41)]
Public string Mobile;
///& lt; Summary> nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related