2

I am working on an asp.net(c#) project for a client. He wanted to add one more team member and that person want to write code in VB.net. So is that possible that for that same project we have pages with different languages ??

Puneet Purohit
  • 1,243
  • 6
  • 23
  • 42

2 Answers2

5

It's possible, kind of. Instead of saying how though, I'm going to say why it's a terrible idea (usually):

  1. The C# programmer will have to get warmed up to VB.Net when a bug is found there
  2. The VB.Net programmer will have to get warmed up to C# when a bug is found there

Sure, you could maybe pretend that each programmer will "own" the code and will never have to deal with the other language... but then

  1. You determine you need another programmer

So, in most cases DON'T DO THAT! Instead, choose one of the other. VB.Net is fine, C# is fine. But mixing them in the same project is stupid and just leads to confusion and frustration

Now, that being said, there are exceptions. Visual Studio doesn't allow for one of intermix languages in a single project, so this basically means you're forced to make the different language portion be a separate library. This is recognized as a shortcoming in Visual Studio, but really, for the reasons said above, this is why this isn't supported(probably).

So, If you're considering using two different languages, ensure the following:

  1. They are separate enough for one to be a library
  2. You'll actually gain some value from using another language (for instance, writing a very stateless and asynchronous library, would benefit from F#)
  3. If #2 isn't satisfied, then ensure that programmers in one language should rarely need to touch the library in the other language. (hint: usually not the case)
Earlz
  • 62,085
  • 98
  • 303
  • 499
2

It's not possible to combine files in different languages in a single project. You can, however, add a project in a different .NET language to your solution.

This may be appropriate if you are adding utility code which you intend to reference from your main project. However, doing it to extend the functionality of an existing application or web site is likely to cause you a lot of headache.

Kirill Shlenskiy
  • 9,367
  • 27
  • 39