Sheri Trager
Sheri Trager

Reputation: 852

combine c# class and vb.net classes

I am using asp.net 2012 and have c# class project where I would like to include some existing vb.net classes.

What would be the best way to be able to use both c# and vb.net classes?

Upvotes: 1

Views: 369

Answers (4)

Rui Jarimba
Rui Jarimba

Reputation: 17944

As already mentioned, one of the alternatives is to convert c# to vb.net or vice-versa. You can find many pages in the internet to do that, like these ones:

http://www.developerfusion.com/tools/convert/vb-to-csharp/

http://www.developerfusion.com/tools/convert/csharp-to-vb/

If you convert the code from one language to the other make sure you test the changes properly.

If you decide to keep VB.NET code in a separate Visual Studio project and reference it in the C# code you need to ensure that the VB.NET code is CLS compliant. This is a good starting point:

Writing CLS-Compliant Code

See also:

Cross-Language Interoperability

Upvotes: 1

coder
coder

Reputation: 13250

Make C# a .NET library and include it in your VB.NET/ASP.NET project.

Follow this http://msdn.microsoft.com/en-us/library/t990ks23.aspx for more info...

Upvotes: 0

kevcoder
kevcoder

Reputation: 955

put the VB.NET classes in a project of its own and then reference that project, just as you would any third party control.

Upvotes: 1

Andorbal
Andorbal

Reputation: 880

Either convert the vb.net classes into C# or put the vb.net classes into their own assembly and add a reference to the assembly.

Upvotes: 4

Related Questions