Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
ASP.NET: Use C Sharp and VB.NET in the same project
From Wiki
Summary: Use C# and VB.NET classes in the same ASP.NET application
Whilst it isn't ideal to both mix C# and VB.NET languages in the same ASP.NET project, it is possible. The code still has to be separated and it can't be mixed at page level but you can create a class in each language and then use and reference them both from any page.
To do this, you'll need to follow a few simple steps.
Step 1
Create an App_Code folder if it doesn't already exist. Then, inside this folder create two other folders to hold each language type. For example,
- App_Code
- vbcode
- cscode
Step 2
Edit your web.config file and make sure the following section is added:
- <system.web>
- <compilation>
- <codeSubDirectories>
- <add directoryName="vbcode"/>
- <add directoryName="cscode"/>
- </codeSubDirectories>
- </compilation>
- </system.web>
Add each class to the relevant folder and you're done! You can now reference any of the classes in the standard manner and ASP.NET will do all of the compilation automatically for you.
This Hack is part of the ASP.NET Hacks collection



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.