Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat would be the C# equivalent of the following struct defined in C++
    text
    copied!<p>I have the following structs defined in C++ used in one of my project which are to be re-used for another project in C# script of Unity engine. I wish to use these struct types as argument types between the C# script and C functions in a dll but I do not know how to convert them into C# declaration.</p> <p>Here are the struct definitions:</p> <pre><code>struct SMove { std::string m_MotionID; std::string m_AnimSrc; float m_StartFrame; float m_EndFrame; // features enum XFEATURE { XFEATURE_NONE = 0, // Insert new features XFEATURE_ENERGY, XFEATURE_POWERLEVEL, }; float m_Intensity; }; struct SElement { float m_Start; float m_End; }; typedef std::vector&lt;SElement&gt; TElements; struct SGroup { float m_Start; float m_End; long m_Level; TElements m_Elements; }; typedef std::vector&lt;SGroup&gt; TGroups; struct SDivision { std::string m_PlayerID; std::string m_DivisionID; float m_Start; float m_End; TGroups m_Groups; // features float m_Intensity; }; typedef std::vector&lt;SDivision&gt; TDivisions; typedef std::vector&lt;long*&gt; TScript; struct SScriptList { TScript* m_Seg[9][4][2]; }; </code></pre> <p>I have just started learning C# and I know it can only interop with C so all std::string and std::vector has to be somehow replace with something recognised in both C and C#. I know std::string can be replaced with const char* but how do I go about converting the rest? I have googled many sites but couldn't find any examples similar to mine. How do I declare arrays of struct inside another struct in C# and its C equivalent like in SDivision and SGroup?</p> <p><strong>Update:</strong></p> <p>I have converted some of the structs to C as follows:</p> <pre><code>struct SElement { float m_Start; float m_End; }; struct SGroup { float m_Start; float m_End; long m_Level; //Array of Elements SElement* m_pElements; int m_numElements; }; struct SDivision { const char* m_PlayerID; const char* m_DivisionID; float m_Start; float m_End; //Array of Groups SGroup* m_pGroups; int m_numGroups; float m_Intensity; }; </code></pre> <p>What would the C# equivalent be?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload