在项目之间使用功能 [英] Using functions between projects

查看:82
本文介绍了在项目之间使用功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个VB.Net 2003解决方案中,我有三个项目(一个在安装程序中

项目,在这里不相关)。然而,另外两个是我想要分享一些普通功能的地方。一个是基于Windows窗体的应用程序和

另一个是Windows服务。这可能吗?


TIA,

-

Anil Gupte
www.keeninc.net
www.icinema.com

In one VB.Net 2003 solution, I have three projects (one in the installer
project and not relevant here). However, the other two are the ones where I
want to share some commone fucntions. One is a Windows Forms based app and
the other is a Windows Service. Is this possible?

TIA,
--
Anil Gupte
www.keeninc.net
www.icinema.com

推荐答案



" Anil Gupte" < a ******* @ icinema.comwrote in message

新闻:OG ************** @ TK2MSFTNGP05.phx.gbl ...

"Anil Gupte" <an*******@icinema.comwrote in message
news:OG**************@TK2MSFTNGP05.phx.gbl...

在一个VB.Net 2003解决方案中,我有三个项目(一个在安装程序中

项目,这里不相关)。然而,另外两个是那些我想分享一些普通功能的地方。一个是基于Windows窗体的应用程序

,另一个是Windows服务。这可能吗?
In one VB.Net 2003 solution, I have three projects (one in the installer
project and not relevant here). However, the other two are the ones where
I want to share some commone fucntions. One is a Windows Forms based app
and the other is a Windows Service. Is this possible?



你把这些函数放在这样的公共类中。


公共类测试


公共共享功能测试(ByVal msg As String)字符串


返回消息


结束功能

/>
结束班级


然后你可以用Messagebox作为例子做这样的事情。


Messagebox(测试。测试(帮助))


您可以将Test类放入项目中。


这只是一个例子。

You put the functions in a public class like this.

Public Class Test

Public Shared Function test(ByVal msg As String) As String

Return msg

End Function

End Class

Then you can do something like this with a Messagebox as an example.

Messagebox(Test.test("Help"))

You can put the Test class in your projects.

It''s just an example.


Anil,


只要你把它们建成Class Librarys就可以用

生成的DLL中的公共方法和属性。


(你必须设置对它的引用)。


Cor

Anil,

As long as you build them as Class Librarys you can do everything with the
public methods and properties in the resulting DLL''s.

(You have to set a reference to that).

Cor




Personaly我会避免使用共享方法,我相信它更适合编码

练习构造一个对象和dis完成它时的姿势

现在我在我的所有自定义类中实现idisposable模式和

使用using语句来确保我不浪费时间

资源


但正如我所说这是个人意见



" Mr。阿诺德" < MR。 Ar****@Arnold.com schreef in bericht

新闻:eF ***** ********* @ TK2MSFTNGP04.phx.gbl ...

Personaly i would avoid shared methods , i believe it is bether coding
practice to construct an object and dispose of it when done with it
nowadays i implement the idisposable pattern in all of my custom classes and
use them with the using statement to make sure i am not wasting anny
resources

but as i said this is a personal opinion


"Mr. Arnold" <MR. Ar****@Arnold.comschreef in bericht
news:eF**************@TK2MSFTNGP04.phx.gbl...

>

" Anil Gupte" < a ******* @ icinema.comwrote in message

新闻:OG ************** @ TK2MSFTNGP05.phx.gbl ...
>
"Anil Gupte" <an*******@icinema.comwrote in message
news:OG**************@TK2MSFTNGP05.phx.gbl...

>在一个VB.Net 2003解决方案中,我有三个项目(一个在安装程序
项目中,在这里不相关)。然而,另外两个是我想要分享一些常见功能的那些。一个是基于Windows Forms
的应用程序,另一个是Windows服务。这可能吗?
>In one VB.Net 2003 solution, I have three projects (one in the installer
project and not relevant here). However, the other two are the ones
where I want to share some commone fucntions. One is a Windows Forms
based app and the other is a Windows Service. Is this possible?



你把这些功能放在这样的公共课上。


公共课测试


公共共享功能测试(ByVal msg As String)字符串


返回消息


结束功能

/>
结束班级


然后你可以用Messagebox作为例子做这样的事情。


Messagebox(测试。测试(帮助))


您可以将Test类放入项目中。


这只是一个例子。


You put the functions in a public class like this.

Public Class Test

Public Shared Function test(ByVal msg As String) As String

Return msg

End Function

End Class

Then you can do something like this with a Messagebox as an example.

Messagebox(Test.test("Help"))

You can put the Test class in your projects.

It''s just an example.



这篇关于在项目之间使用功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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