如何在c#项目中使用.vb类 [英] how to use .vb class in c# project

查看:107
本文介绍了如何在c#项目中使用.vb类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好;

i是软件开发中的新蜜蜂..



i在VB.net中有一个类名为abc.vb

我可以在c#.net桌面应用程序项目中使用这个类.. ??

如果是..如何.. ??

如果不...为什么.. ???

解决方案

是的,你可以。如果将VB类编译为程序集(DLL)。



然后可以添加VB程序集作为对C#项目的引用。



很难做到的是在同一个项目中混合VB和C#。


是的,你可以使用它。如果将VB项目编译为类库(dll),则可以在C#项目中引用该库。为了从C#项目访问类型及其成员,必须将它们定义为公共。





一个教程: http://www.vbdotnetheaven.com/uploadfile/mahesh/buildingclasslibrary04262005091233am/buildingclasslibrary.aspx [<一个href =http://www.vbdotnetheaven.com/uploadfile/mahesh/buildingclasslibrary04262005091233am/buildingclasslibrary.aspx\"target =_ blanktitle =New Window> ^ ]


< blockquote>将你的vb文件放在vb文件夹中,将.cs放在root的cs文件夹中



在web.config中

在system.web下br />
< compilation>

< codeSubDirectories>

< add directoryName =vb/>

< add directoryName =cs/>

现在关闭所有标签


hello everyone;
i am new bee in software development..

i have a class in VB.net names as abc.vb
can i use this class in c#.net desktop application project ..??
if yes .. how ..??
if not ...why ..???

解决方案

Yes you can. If you compile your VB class to an assembly (DLL).

You can then add the VB assembly as a reference to you C# project.

What it is difficult to do is to mix up VB and C# in the same project.


Yes, you can use it. If you compile the VB project to a class library (dll) you can reference that library in your C# project. In order to access the types and their members from the C# project, they must be defined as public.


One tutorial: http://www.vbdotnetheaven.com/uploadfile/mahesh/buildingclasslibrary04262005091233am/buildingclasslibrary.aspx[^]


Put your vb file in vb folder and .cs in cs folder in root

In web.config
Under system.web
<compilation>
<codeSubDirectories>
<add directoryName="vb"/>
<add directoryName="cs"/>
Now close all tags


这篇关于如何在c#项目中使用.vb类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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