tags:

views:

323

answers:

3

I wanna use the C# code file in VB.Net project Which is windows based application. But that C# class is not using in VB.NET application. How Can I perform this task.

Thanks

+5  A: 

Compile the C# class in it's own C# class library (DLL) and then in your VB project, add a reference to the C# DLL. You can then use the class in your VB project.

If, however, you want to include the source code of the C# class in your VB project then you will have to convert the class from C# to VB. There are various methods of doing this, such as the online tool Convert C# to VB.NET

AdamRalph
I don't want to make library because that is a single class.
Deepak
@Deepak - I have added the second paragraph in response to your comment
AdamRalph
Thanks, I have converted that code and it is also running but As well as we can do in ASP.NET so I want to use this like web application reference.
Deepak
@Deepak - sorry I don't understand the last part of your comment
AdamRalph
I meant to say as we get reference of different language class file in asp.net to put it in APP_code's sub directory and do configuration in web.config's compilation tag. AS like can we do in windows application by any technique?
Deepak
if I understand you correctly then the answer is no, you cannot include a C# source code file in a VB Windows application in the way you can with a web site. You will have to use one of the tecnhiques I describe in my answer
AdamRalph
A: 

You can also add the reference for an executable, if it is a .NET assembly. So just compile your C# project and add it as reference into your VB project.

Simon Linder
Thanks,I know this thing. But As we use vb.net individual class in C# project of ASP.NET. Then we put it in APP_Code's Child Directory and Specify it in web.config's compilation->codeSubDirectories tag. Same I wanna use single class of C# to vb.net windows application.
Deepak
Well then I don't think that you can do it, except for web projects. I think you have to reference some kind of assembly. How about adding a new C# project into your solution and just add your existing .cs file, compile it as Dll and add the reference.
Simon Linder
A: 

cannot. period. translate to vb.

Sky Sanders