using managed c++ dll in c#
<pre><code>**unmanaged class**
</code></pre>

<p>this is the unmanaged class declaration</p>

<pre><code>#ifdef EXPORT_CLASS
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
public class DLL_EXPORT cppclass
{
private:
string x;
public:
cppclass();
~cppclass();
string native();
};


**UNMANAGED CLASS DEFINITION**
</code></pre>

<p>this is the unmanaged class definition</p>

<pre><code> cppclass::cppclass()
{
x="hello";
};
cppclass::~cppclass()
{
};
string cppclass::native()
{
return x;
};

**MANAGED CLASS**
</code></pre>

<p>this is the managed class declaration</p>

<pre><code>public __gc class Mclass
{
//private:
public:
cppclass * obj;
public:
Mclass();
~Mclass();
string native();
</code></pre>

<p>};</p>

<pre><code>**MANAGED CLASS DEFINITION**
</code></pre>

<p>//this is the managed class definition</p>

<pre><code>#include"managed.h"
Mclass::Mclass()
{
    obj=new cppclass();
};
Mclass::~Mclass()
{
    delete obj;
};
string Mclass::native() 
{
return  obj-&gt;native();
};

Now all this is made into a dll and imported in a c# project


using managed;

 namespace ConsoleApplication1
 {
 class Program
 {
    static void Main(string[] args)
    {
        managed.Mclass first = new Mclass();
        String x=first.nativ();
        Console.Out.WriteLine(x);
    }

}
</code></pre>

<p>}</p>

<p>error comes that Managed.Mclass.nativ() is not supported by the language</p>
