14

I know C# is different from .NET Framework, C# is a programming language that standard by ECMA (ECMA-334) and ISO (ISO/IEC 23270).

I don't want a converter that converts ANY C# source code (including .NET Framework) to C, but I want a tool that converts an ECMA standard C# source code to ANSI C source code.

Something like java2c but for ECMA C#.

mindless.panda
  • 4,014
  • 4
  • 35
  • 57
Amir Saniyan
  • 13,014
  • 20
  • 92
  • 137

2 Answers2

5

There is not exactly such thing, but the Vala programming language is able to take a source code very similar to C#, and generate C codem or compile it directly.

http://live.gnome.org/Vala

Of course, the only problem are the libraries: C# has a lot of API's that you'll have to provide, or modify your source code to adapt to the Vala standard library.

If you wanted to translate this code to C because you need it compiled, there are other possibilities.

For example, ngen in the microsoft world:

http://msdn.microsoft.com/en-us/library/6t9t5wcf(v=vs.80).aspx

In the mono project, you can create a single exe file with the interpreter and the libraries. Look for mkbundle:

http://www.mono-project.com/Mono:Runtime

Mono is able to compile "ahead of time", i.e., generate the native code even before the program is going to be executed, so it will run faster.

http://www.mono-project.com/Mono:Runtime#Ahead-of-time_compilation

Baltasarq
  • 12,014
  • 3
  • 38
  • 57
-1

Depends on what you mean. If you mean "Is it possible to convert C# to readable and maintainable C-code?", then sorry, the answer is no — C# features don't directly map to C.

Zoe
  • 27,060
  • 21
  • 118
  • 148
  • (This post does not seem to provide a [quality answer](https://stackoverflow.com/help/how-to-answer) to the question. Please either edit your answer, or just post it as a comment to the question). – sɐunıɔןɐqɐp Jun 09 '18 at 13:15
  • If could post as comment would do it. But as see I new here so don't have that option. I want add comment it not easy make readable code when convert from C# to C. have not right do so had make answer instead. I have use tools my self for this. It compiling code but not easy maintain. – Young Developers Jun 09 '18 at 13:26