Native C++ to C#
<p>I want to use C++ class in C#.</p>

<p>In C++ my .h file is like this:</p>

<pre><code>struct XMFloat3
{
public:
    float x;  float y; float z;

    XMFloat3(){}

    XMFloat3(float _x, float _y,float _z)
    {  
        x = _x;
        y = _y; z = _z; 
    }  
};

class Car
{
public:
    XMFloat3 m_position;
    char* m_name;
    int m_model;
    double m_price;

    void setPosition(XMFloat3);
    void setName(char* );
    void setModel(int);
    void setPrice(double);

    XMFloat3 getPosition() { return m_position; }
    char* getName() { return m_name; }
    int getModel() { return m_model; }
    double getPrice() { return m_price; }

    void SetInformation(XMFloat3 position,char* name, int model,double price);
    ~Car(void);
    static Car* getInstance();

private:
    Car(void){ }
    Car(XMFloat3 position,char* name,int model,double price){ }
    static Car* instance;
};
</code></pre>

<hr>

<p>I create clr\library project with Wrapper Class definition like:</p>

<pre><code>public ref class WrapperClass
{ 
public:
    WrapperClass();

    void setInformation(XMFloat3 position,String^ name,int model,double price);

    void setPosition(XMFloat3);
    void setPosition(float x,float y,float z);
    XMFloat3 getPosition() { return obj-&gt;getPosition(); }
    void setName(String^ name);
    String^ getName() { return gcnew String(obj-&gt;getName()); }

    void setModel(int);
    int getModel() { return obj-&gt;getModel(); }

    void setPrice(double);
    double getPrice() { return obj-&gt;getPrice(); }

    float getX() { return obj-&gt;getX(); }

    ~WrapperClass();
private:
    Car *obj;  
};
</code></pre>

<p>.....................................................................................</p>

<p>But when i use this Wrapper class function getPosition() in C#, in C# getPosition() Declaration is like: </p>

<pre><code>XMFloat3* getPosition(XMFloat *);
</code></pre>

<p>That's not perfect for my use please tell me if i doing any wrong up there or suggest how to use User Defined Datatype in such scenario.</p>

<p>And 2nd question is How User Defined data types are access or use in C#. e.g if i want to pass XMFloat3 data from C# how is it possible?? (I create XMFloat3 struct in C# .cs file and try to use it but its give type matching error.</p>

<p>In C# setPosition declaration for Wrapper Class is like:
    public void setPosition(XMFloat3 t);
Error is Type Mismatch CSharp.XMFloat3 to WrapperDll.XMFloat3.</p>

<p>Please tell me how to use above Class in C#.</p>

<p>Thanks</p>