简体   繁体   中英

Using vb.net classes in c#

How can I create a type in vb.net and use the type in c#? I guess I need to compile the vb project and add reference to the dll but have no idea if this is the right way to do it, or the reference will be valid. Doing this is not for fun, we have some vb code and we're considering this option.

Just create a Class Library project in VB, and then add a reference to that project from your C# project. (Or if it's in a different solution, add a reference to the DLL created by the VB project.) It should be absolutely fine - you'll have access to all the Public types from your class library.

To address the comment in your question, the projects can both default to the same namespace, but it's generally a better idea to make each project have its own namespace, so it's clear where any particular type comes from.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM