在同一个应用程序中使用 VB.NET 和 C#? [英] Use VB.NET and C# in the same application?

查看:15
本文介绍了在同一个应用程序中使用 VB.NET 和 C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 MS Visual Studio 2005 中开发基于 GUI 的应用程序,我只想知道是否可以在同一个项目中同时使用 VB.NET 和 C#.或者我可以在我的 VB.NET 项目中包含一个用 C# 编写的模块吗?

I am developing a GUI based application in MS Visual Studio 2005, I just want to know if it is possible to use both VB.NET and C# in the same project. Or can I include a module written in C# in my VB.NET project?

我有一个用 C# 编写的类,我想在基于 VB.NET 的项目中使用它,所以如果我可以包含和调用该项目中的函数,那么我就不必在 VB.NET 中再次编写该类.

I have a class written in C# which I want to use in my VB.NET based project, so if I can include and call functions from that project than I won't have to write the class again in VB.NET.

所以请帮助我,因为我是 .NET 编程的新手.

So please help me as I am new to .NET programming.

推荐答案

我自己从来没有做过,但我知道你可以将 C# 代码编译成一个 dll,然后在你的 VB 项目中加载和引用这个 dll.

I've never done it myself, but I know you can compile the C# code into a dll and then load and reference the dll in your VB project.

来自在 VB.net 中调用 C# 类":

我认为你想要的 C# 代码使用必须编译为 DLL.一次大功告成,简单添加一个引用到该项目到您的 VB.Net项目,导入你的命名空间需要,然后你可以使用C#代码.

I think the C# code that you want to use must be compiled as a DLL. Once that is done, simple add a reference to that project to your VB.Net project, import the namespace you need, and then you can use the C# code.

另请参阅如何:创建和使用 C# DLL(来自 MSDN,用于 VS2005)

Also see How To: Create and Use C# DLLs (from MSDN, for VS2005)

这篇关于在同一个应用程序中使用 VB.NET 和 C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆