I have to execute project where I need to migrate Borland C++ code to C#, what are the important steps I need to follow for smooth migration of code? and please suggest any kind of Tips and Tricks?
It's not really going to be a migration of code though, is it? What you're doing is essentially rewriting a system that exists in language a (C++ in this case) in language b (C#). The two languages don't have that much in common to facilitate an easy mechanical translation (C# <-> Java is much easier to translate mechanically) and depending on how modern the C++ code is you might not be able to translate some of the idioms directly.
My approach for a reasonable size project would be to write a "cross-compiler" in a language that allows for easy text processing (I used ruby the last time around). This cross-compiler should be able to mechanically translate about 80% of the code into something that is almost compilable in the target language. This also allows you to identify the areas of the code that need (lots of) attention from a programmer because you'll have to take the existing code and write a functional equivalent in C#. Don't forget that for this translation tool, you'll also need to write code that can pull together the necessary bits of code from header files and implementation files. Depending on how well organised the C++ code is, this is a non-trivial task.
That actually means a complete re-write. If I were you, I'd try C++/CLI instead of C#. This way, you can acutally gradually rewrite your code and transform it to managed code.
Things to consider, wether you migrate to C# or C++/CLI:
- Partition your software in modules with clean interfaces (using n-tier architectures, MVC, ...). If each partition is a COM-object, you can even try to migrate only parts and use the COM objects in .NET.
- Identify the libraries you depend on and check how you can replace them in .NET
- Determine where you use pointers and check how you can transform this code in C++
- Check where you use RAII-objects and find a way to get the same result in .NET.
I can't give you more detailed advice as I don't know what type of program you want to migrate and for what reason.
If you just want to move to .NET then consider using C++/CLI. If you really want to move to C# then what I would suggest is not using an automated migration path but rather after moving to C++/CLI, do new development in C# and have a plan to move the existing code from C++ to C# once there is a robust test environment in place to validate the changes made over time.
But if you simply must do a big-bang migration then you could consider porting to C++/CLI to build managed assemblies and use one of the disassmble-IL-to-C# tools to automate the process. I'm strongly against doing that - but it's your time and project, not mine.