Translating Code from C++ to C#

  • Thread starter Thread starter IF
  • Start date Start date
I

IF

Could someone please tell me, how easy or difficult , it is to transfer code
written in C++ to C#.

I wrote a program for FTP ( in C++), and need to translate that code in C#.
As a beginner of C# I'm not sure how much work is required, and I wanted to
get a feel of it before I started.

If someone could advise.

Thanks
Idris
 
It depends if you use new-style declarations (like the 'new' keyword) or
old-style (like malloc()) - the new-style is quite similar to C#. The main
problem is really memory management and pointers. If your app has tons of
pointers to structures (yuck!!) then you will likely be doing a lot of
coding...

The bottom line is if you took all the pointers and memory management out of
C++ - what's leftover is VERY simlilar to C#..
 
It depends entirely on the C++ style. If the C++ programmer expressed the
algorithm straightforwardly, using simple data types, then it will be easy.
If it's full of C++ tricks and obscurities, it won't be.
 
>Could someone please tell me, how easy or difficult , it is to transfer code
>written in C++ to C#.

In addition to the other replies, which focus on the language issues, there
are the underlying platform issues.

It could be as simple as replacing socket with Socket and similar
substitutions, though I haven't looked at the two interfaces (Platform SDK
and .Net Framework) to see if there's more to it that that. And if your
C++ code is for UNIX, it could be far worse. I have no way of knowing
whether you'll come up against any serious problems in regard to this, but
even if you don't, dealing with the platform issues can be far more tedious
and error-prone than just dealing with the language issues.

Gary
 
Back
Top