How to convert C # to C ++

Can someone help me convert C # to C ++? here is an example:

using System; using System.Net; using System.Text; using System.IO; using System.Threading; namespace read_website { class Program { static void Main(string[] args) { ... } ... } } 

Actually, since it is difficult to mix C # and C ++ in unix, I am trying to convert C # to C ++ so any help would be greatly appreciated

Thank you for your reply, help and time.

+8
c ++ c #
source share
10 answers

Actually, since it is difficult to mix C # and C ++ in unix, I am trying to convert C # to C ++

Did you consider Mono ? This is something that is definitely worth checking out before starting to learn C ++ to convert and run an existing .NET application on Unix. It is also a binary compatible value that you don’t even need to recompile an existing assembly.

+21
source share

It is almost impossible to directly translate C # to C ++ so that it works on Unix machines.

This is mainly due to the fact that the .NET Framework is not available (from C ++) on Unix machines. Mono will let you run many C # / programs. NET, but does not support C ++ / CLI (C ++ extensions that allow you to work directly with the .NET Framework).

Language conversion is possible - although difficult due to differences in approach (for example, garbage collection in C #), structure calls require porting to different libraries, and this is often not a good candidate for direct translation.

For example, in your code above, you will need to select a C ++ library to access the network - and after you make this choice, it will determine the code needed to call this library to load the website line.

+8
source share

Learn C #, learn C ++ and spend a lot of time rewriting.

Or use the PInvoke from the C # assembly to call in the C ++ dll.

Or write managed C ++ and compile with the / clr switch . The resulting assembly can be referenced and used from C # projects.

+7
source share

I use C # to C ++ Converter from time to time. This is really great for converting fragments from C # to C ++ or C ++ / cli.

+5
source share

Look at Vala. Vala is a C # -shaped language that translates to C and then to an executable file. There are very few differences with C #. You still have to use your brain, though.

+4
source share

Edit:
The listed site has been discontinued. I will leave the old answer here for reference ...

Old answer:
Here is an online converter that automates the process for you! ...

Online Converter Varycode

It can do C # in C ++ and vice versa, as well as converters for Ruby, Python, Java and VB, apparently!

Edit:
It seems that its C ++ (and java) functionality has been removed - it speaks temporarily, but has done so for a long time. I hope they will be resurrected soon!
Still works for some other languages ​​(VB, Ruby, Python, Boo).

+3
source share

You might want to consider CoreRT. This is a .NET project that aims to eliminate the need to use the CLR on the target platform to run the application. Instead, it generates C ++ code from the given C # code. This C ++ code is compiled and linked on any target platform that supports C ++.

A Microsoft blog post says: “If I really want to write C # code and just work” on a new IoT device, I have no parameters until RyuJIT can generate machine code that works with this processor and operating system " Using C # cross-compilation in C ++, .Net developers can deliver their applications without having to wait for .Net to be deployed on this platform.

https://github.com/dotnet/corert

+2
source share

Here is a website where you can find a C # to C ++ converter.

https://github.com/ASDAlexander77/cs2cpp

You just need to follow some steps to create and compile C ++ code with C #. In addition, this application converts C # code to C ++, compatible with cross-platform.

+1
source share

As mentioned here, translating libraries may be a problem, but one open source project that may help in some cases:

http://alexalbala.imtqy.com/Alter-Native/

Quote from the main page:

It provides a tool for convenient port applications from high-level languages ​​such as .NET to native languages ​​such as C ++. This is a research project being developed jointly with UPC - BarcelonaTech and AlterAid SL

0
source share
  static void Main(string[] args) { int t = int.Parse(Console.ReadLine()); for (int i = 0; i < t; i++) { string []a = Console.ReadLine().Split(); string[] b = Console.ReadLine().Split(); int n = int.Parse(a[0]); int k = int.Parse(a[1]); int c = int.MinValue; for (int l = 0; k<=n; l++) { for (int j = l; j < k; j++) { if (int.Parse(b[j]) > c) c = int.Parse(b[j]); } k++; Console.Write(c); c = int.MinValue; } } 
-3
source share

Source: https://habr.com/ru/post/650894/


All Articles