我的結構++是以下我想從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