I know that .Net provides the feature to mix several languages within the same application (there are some constraints of course, but this is not essential). Theoretically, this might be done because the languages supported by .Net do not fully expose all the features it can provide. IL does of course. So when you need a feature that the current language doesn't provide, you could write it in another .Net language. The whole code would be translated into IL, and so you would gain more features.

From my personal experience, I was writing a project in C# and needed to integrate a small project written in C++ under .Net. When I consulted with some more experienced programmers, they said that it would be much easier to "translate" the C++ code into C# than integrate it. Since I had little time, it was what I did, and it was quite easy (the project was quite small).

So my question is, has anyone experienced a real-life situation when mixing languages is an absolute necessity?


The best real-world scenario I've encountered is when you want to access C++ classes from a managed environment, say from a C#-based application.

C# can access unmanaged COM classes using COM Interop, or unmanaged C-style APIs like the Win32 API using P/Invoke/DllImport, but it can't access normal non-COM C++ classes and APIs. If you've got a need to do that, easiest way is to write a component in C++/CLI.

Since the component is a managed, .NET component, it can be easily called by your C# code. Since it's C++, it can instantiate C++ objects and call unmanaged APIs. Everyone is happy.

| improve this answer | |

This feature can be used in ASP.NET website development.

I had an occasion where project was initially developed in VB.NET and required some new additions (new web-forms). After analyzing pros and cons as well as timeline, i have decided to add new forms in C#, as it was my primary language of development. Everything went pretty well for that small project.

However, there might be some disadvantages/side-effects for relatively big projects, where languages are mixed.

Note: you can use only one .NET language in ASP.NET web application

| improve this answer | |

I did work on a project where we had a UI written in VB.NET, and calculations written in C#. This was primarily due to the UI developer not having experience in C#, and the calculation developer having no experience in VB.NET. With .NET, everything just worked together.

Ideally, the developers should have agreed on the language, but it did work for a rapid project completion time (no language ramp up).

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.