C to C#

  • Thread starter Thread starter ZakHurst
  • Start date Start date
Z

ZakHurst

I know we are lagging behind but with limited resources
and time we are looking at how we can convert some of C
applications to C# without re-writing from scratch.

We want to be in position as quickly as possible where we
can start re-writing areas in C#
 
static methods for functions :D

delegates for callbacks

package into a class, oh and no header files
 
Converting from C to C# would most likely be a complete rewrite. C# is
actually more like VB than it is like C/C++. Other than the syntax, C#
really doesn't have anything in common with C.

Chris LaJoie
 
Another alternative is to port your C to managed C++ (essentially a superset
of C). Microsoft recently released a demo of - was it Quake??? - ported
from unmanaged code into managed code, proving how good their C++ port to
..NET is.

Once you have the C code firmly in place in .NET, it should be a relatively
minor effort to selectively rewrite parts or add new functionality using C#.
Over time, your code base will become more and more C#-based, and your code
will work from day one.
 
ZakHurst said:
I know we are lagging behind but with limited resources
and time we are looking at how we can convert some of C
applications to C# without re-writing from scratch.

We want to be in position as quickly as possible where we
can start re-writing areas in C#

That smells like a rewrite. C is based on pointers. C# supports
pointers but in unsafe mode which kind of defeats the purpose of .NET
framework.
 
Frank Rizzo said:
That smells like a rewrite. C is based on pointers. C# supports
pointers but in unsafe mode which kind of defeats the purpose of .NET
framework.

C# really does support pointers in managed code. Passing in an object reference or value type reference into a function is passing
in a pointer. Not that I think this will help avoid a rewrite :-)
 
I think what will pain you the most in this endeavor is the standard
libraries vs the .net framework. Just about everything done in C is done
via the libraries, that is to say C's core language is very minimal.
Everything from printing to the console, to string manipulation (both very
common in C) will have to be rewritten from scratch to use the .net
framework methods.

I prefer one of the earlier suggestions of converting to C++, which will
lead you into a later step towards managed C++ (.net C++). If you need to
convert quickly, that would probably be the best suggestion.
 
C++ supports pointers in managed code, and there is nothing stopping you
from building the application from the bottom up, a little at a time, using
C# and calling the new code from C. That way, your C code doesn't change
all that much, most new development can be done in C#, and you are not faced
with a long rewrite cycle before your next release (this will ease the mind
of management - trust me).

Michael Culley said:
C# really does support pointers in managed code. Passing in an object
reference or value type reference into a function is passing
 
Back
Top