c# - Wrapper a class(Native c++) using managed C++, how to do about the native struct? -


namespace mcwrapper { struct s1 {     int n1;     int n2; }; class c1 { public:     void test(s1* ps1)     {      }; };  public ref class class1wrapper { public:     class1wrapper()     {                    _pc1 = new c1();     };     void test(s1* ps1)     {         _pc1->test(ps1);     } private:     c1* _pc1; };} 

build it, can .net dll .

create c# client use dll:

//c#      public form1()     {         initializecomponent();                     var c1 = new mcwrapper.class1wrapper();         //we can find test method , cannot type codes like: s1*         c1.test()//?????????????????????????????????      } 

i cannot run class1wrapper.test in c#.

then have tried change test() test( int^ n), found c# explain test(int^n) test(valuetype n) have been confused, everybody.

so, should set new managed struct like:

public value struct css1{int n1;int n2}  

and change test(...) from

class1wrapper::test(s1* ps1){_pc1->test(ps1);} 

to

class1wrapper::test(css1* pcs1) {     s1* ps1 = new s1();      ps1.n1=pcs1.n1;      ps1.n2=pcs.n2;     _pc1->test(ps1);     delete ps1; } 

its hard work wrapper. , think wasting time . there no other way else?


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -