VB.Net and C-Sharp


I have a problem in VB.Net that can only be solved in C# (problem with casting). I have made a C# class (from an example), is it possible to link this class into my VB application ? Or how can I use this class ?

Who is Participating?
Create a new C# class library solution, build the solution.

Now in your VB solution, in the solution Explorer, right click on "References" -> Select "Add Reference" browse to your file and add it (I'll assume your solution was called myClassLib and the class is called myClass)

Now you can use

Dim c as myClassLib.myClass 'etc......

Complie the class and add a reference to it.
ACAEAuthor Commented:
I can't seem to get it working. I added my class to my project (right-click on project --> Add --> Add existing item), selected the class (cs file), and build the project. But now i cannot add a line like

DIM localclass AS NEW csharpclass

this gives the error Type 'csharpclass' is not defined

Perhaps I used the wrong definition for 'class', it is a source file not a project
ACAEAuthor Commented:

Thx for your help, it works fine for me now.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.