Click here to Skip to main content
16,006,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to use C# and vb code in a single windows project ?
If YES, can some1 plz, provide me a sample code..?

I know that its possible in asp.net, I even tried it using this link.
I just wanted to know is there any method to use it in windows project..?

Thnx :)
Posted
Updated 15-Jul-10 20:50pm
v2

1: Why would you want to? Is there a compelling reason to do so? If not, then don't.
2: Yes: Create 1 solution with 2 projects. One of the projects is a library of functionality created in C# or VB. The other is the main project created in C# or VB which references the functionality in the library.
 
Share this answer
 
Yes, it's possible. There used to be an example in SDK v1.1
called: CrossDevLanguage.

See here.
 
Share this answer
 
Yes, but it is bad practice.
Stick to one language.

You can write in both within a series of webpages and call routines in either language, but it is ugly and crude and should be avoided.
 
Share this answer
 
This is possible in ASP.NET because each page is loaded seperately, only for the page lifecycle. Your many pages are never compiled all at once. However, even in an ASP.NET project, your app code classes all need to be one or the other. The only way to get around that requirement in ASP.NET is the same way you get around it in a windows app. Your Windows app MUST be all VB.NET or all C#. However, it can load any .NET dlls you like, and they must also be ALL VB.NET OR all C#. In other words, your C# app can consume a VB.NET dll, and vice versa.
 
Share this answer
 
Comments
R. Giskard Reventlov 16-Jul-10 3:39am    
That's not quite right: It is possible to have both VB and C# classes in the app_code folder. See here: http://msdn.microsoft.com/en-us/library/t990ks23%28VS.80%29.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900