[quoted text, click to view] vijay.gandhi@gmail.com wrote:
> 1. I believe it is possible to convert C++ to C++/CLI. Is it possible
> to convert the C++ code to C#?
The C++/CLI language is built upon C++. Your C++/CLI code can directly
use C++ classes, and call C++ code.
[quoted text, click to view] > 2. If moving to C# is possible, then what would be a better choice -
> C# or C++/CLI?
You could use C++/CLI to wrap native ISO C++ classes into managed
objects, which can then be used in any .NET langauge. Typically you do
the wrapping this way:
class OldNativeClass
{
public:
void Method();
};
public ref class ManagedWrapper
{
public:
ManagedWrapper() : p(new OldNativeClass) { }
~ManagedWrapper() { delete p; }
!ManagedWrapper() { delete p; }
void Method() { p->Method(); }
private:
OldNativeClass* p;
};
Once you compile this into a CLR Class Library project, it generates a
DLL that can be consumed by C# directly. ManagedWrapper will be
available, but OldNativeClass will not be.
If your requirement is to create a fully managed output from native C++
code, that has some limitations, depending on whether you need a fully
verifyable assembly or not. Generally speaking, the first step in
porting legacy could should be based on wrappers, so that you can use
your existing C++ code from C#. Once you have accomplished that, and you
are not allowed to use native code at all, then you can worry about
replacing your legacy solution with a fully managed one.