C++ with C#, is it possible?

Asked

Viewed 521 times

8

I have a C++ project using visuals on it using wxWidgets.

I was hoping to transfer the look of the project to C#.

It is possible to have the programming of the functions in C++, but the programming of the whole visual in C#, that is, the buttons call the functions in C++?

  • This is to do, if you submit all the actions of the form by Web Service, but, I do not advise doing this. Maybe, there is someone there who knows another alternative, but I think it doesn’t exist, because C++ uses a compiler and C# uses another.

  • this would be a brave and needless gambit, if it will migrate to a language more parruda, it would not be much easier to adapt the syntax of the functions to C#, the logic would remain the same.

  • I’d say stay in the C++.

  • The problem is that I have more than 5 thousand lines ready, I would like to put a visual to the program, without needing the wx extension....

  • 1

    It depends a little on how your code is, but one option is to turn the C++ part into a DLL, which you can use in the program written in C# (which would be in charge of the interface elements and their Event handlers).

  • I get it, you could explain to me better how I do it??

  • @Stephen Take a look at [tour]. You can accept an answer if it solved your problem. You can vote for every post on the site as well. Did any help you more? You need something to be improved?

Show 2 more comments

1 answer

7

It is possible using the C++/CLI. This is a managed version of C++ that is used with . NET.

I won’t go into too much detail because you probably don’t want to use it. In fact it is usually only used as glue between native C# and C++ applications. That is, you will do the main part of the application in C#, and use the C++/CLI to give C# access to native C++ written functions.

Of course it is possible to use the C++ code in C++/CLI. It is not pure C++ but it is very similar in almost everything. But it’s almost certain to require some adaptations.

Avoid doing this, but there’s a possibility. If you are going to switch to C# think carefully if there is any reason to leave a part in C++, usually you do not need, you will only create complications without having any benefit.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.