Converting a C program to C#

G

Gilgamesh

I have a program written in C which I need to convert it to C#. This program
includes about six header files and it makes calls to functions which havee
been defined in other C programs . How can I convert only this program to C#
without bothering about other C programs used by this program? Do I need to
just add the include files in the project? What's the best way to develop
this?

Any feedback will be greatly appreaicted.

Thanks,
Gilgamesh
 
G

Guest

Perhaps start from scratch.? (realistic.)

You whould have to atleast list the program that you are trying to convert.
We havent a clue as to the scope of your program.

I have to warn you, c code and managed c# code can be completely different
beasts.

As for the rest of your classes, if they are in a dll, you most likely could
reuse them.

If your code works just fine, why convert?
 
A

Ashot Geodakov

Not sure about C#, but you can always compile this project with added CLR
support.

Right-click on project => Properties => Common Language Runtime support =>
Select CLR support in the combo box => Apply.

I can guarantee it will not compile at once. You will need to change other
project's settings. Read MSDN (Common Language Runtime Compilation), which
will explain a bit.

Once this compiles successfully, you can define managed C++ classes in it.
This will turn the project into a .Net class library assembly. Then you can
add references to this assembly in other projects, C# or Vb.Net.
 
M

Mark Rae

I have a program written in C which I need to convert it to C#.

Why? Has it stopped working...?
This program includes about six header files

*About* six...? Is that five, six, seven...? Do you not actually know how
many headers are included...? You will need to get a complete picture of
what the C program is doing before you can proceed with this...
and it makes calls to functions which have been defined in other C
programs.

And what are they...?
How can I convert only this program to C#

Impossible to advise you with the level of information you've provided so
far...
 
M

Michael A. Covington

Despite similar syntax, C and C# are radically different languages. C uses
pointers extensively but C# does not (instead, pointer-like things are done
for you by the object-oriented type system). Unless the conversion is
necessary for some reason, I would recommend not doing it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top