我的结构++是以下我想从C元帅一个结构到C#,不知道从哪里用C开始
/* this structure contains the xfoil output parameters vs angle of attack */
typedef struct xfoil_outputdata_struct
{
double *pAlfa;
double *pCL;
double *pCM;
double *pCDi;
double *pCDo;
double *pCPmax;
long nEntries;
} XFOIL_OUTPUT_DATA;
/* Here are the function prototypes for XFoil */
__declspec(dllexport) XFOIL_OUTPUT_DATA *xfoilResults(); /* get output from xfoil */
我用XFoilResults拉这种结构回C#
我DLL Imports语句如下:
[DllImport("xfoilapi.dll")]
public static extern void xfoilResults();
这是正确的吗?我无法控制C++代码。我只需要能够将结构拉入C#。 C#的结构我至今是以下
[StructLayout(LayoutKind.Sequential)]
public struct xfoilResults
{
IntPtr pAlfa;
IntPtr pCL;
IntPtr pCM;
IntPtr pCDi;
IntPtr pCDo;
IntPtr pCPmax;
long nEntries;
}
我怎么能填充这个C#结构与C++代码的数据?
有什么部署方案?如果您可以在应用程序中支付额外的.dll文件,那么使用C++/CLI来处理这些内容会让您的生活更加愉快。它可以直接通过#include使用C++结构定义,使用C++语法提取数据,并将其填入一系列'System :: Generic :: Collections :: List'或.NET数组对象('cli :: array ')以供C#进一步使用。 –
2010-12-16 19:43:37