混合C#和放大器; VB在同一个项目 [英] Mixing C# & VB In The Same Project

查看:147
本文介绍了混合C#和放大器; VB在同一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能在一个类库同一个项目中混合使用VB和C#文件?有一些设置,使得它可以?

Can you mix vb and c# files in the same project for a class library? Is there some setting that makes it possible?

我试过,没有智能感知的作品相当正确,虽然后台编译,似乎从一个事实,即我的话,有2个班在具有相同名称相同的命名空间处理的不够好(除了它没有抱怨)。

I tried and none of the intellisense works quite right, although the background compiler seems to handle it well enough (aside from the fact that I, then, had 2 classes in the same namespace with the same name and it didn't complain).

我们正试图从VB转换为C#,但没有完成转换所有code。我有一些新的code我需要写,但并没有真正想使一个新的项目只是为了它。

We're trying to convert from VB to C# but haven't finished converting all the code. I have some new code I need to write, but didn't really want to make a new project just for it.

推荐答案

没有,你不能。组装/项目(每个项目编译成一般为1装配)必须一种语言。但是,您可以使用多个组件,每个人都可以在不同的语言codeD,因为它们都被编译成MSIL。

No, you can't. An assembly/project (each project compiles to 1 assembly usually) has to be one language. However, you can use multiple assemblies, and each can be coded in a different language because they are all compiled to MSIL.

它编译罚款,没有抱怨,因为VB.NET工程只会实际编译的.vb文件和C#项目仅实际上将编译的.cs文件。它忽略了其他的,所以你没有收到错误。

It compiled fine and didn't complain because a VB.NET project will only actually compile the .vb files and a C# project will only actually compile the .cs files. It was ignoring the other ones, therefore you did not receive errors.

编辑:如果您添加一个.vb文件到C#项目,选择在解决方案资源管理器面板上的文件,然后看一下属性面板中,你会发现,生成操作是'内容,而不是编译。它被视为一个简单的文本文件,甚至不会嵌入在编译的程序集作为二进制资源。

If you add a .vb file to a C# project, select the file in the Solution Explorer panel and then look at the Properties panel, you'll notice that the Build Action is 'Content', not 'Compile'. It is treated as a simple text file and doesn't even get embedded in the compiled assembly as a binary resource.

编辑:使用asp.net网站,您可以添加C#web用户控件vb.net网站

With asp.net websites you may add c# web user control to vb.net website

这篇关于混合C#和放大器; VB在同一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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