在类库访问方法 [英] Access method in class library

查看:140
本文介绍了在类库访问方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感动的一类在我的项目到相同的解决方案类库。我已在web项目的类库引用。

I've moved a class in my project into a class Library in the same solution. I've added a reference in the web project to the class library.

我如何访问这些方法在类库?

How do I access the methods in the class library?

推荐答案

确认的方法和类的发布和实例,并使用它:

Make sure the method and class is publish and instantiate and use it:

YourClass yourClass = new YourClass();
yourClass.YourMethod();

或者,如果你的方法是静态的:

Or, if your method is static:

YourClass.YourMethod();

请务必注明您的类的命名空间using语句目标类,即

Make sure to include the namespace of your class is your target classes using statements, i.e.

using ClassLibrary;

如果你不确定 YourClass 的命名空间,你可以在上面的类文件中找到它,你使用的语句的正下方。通过单击显示的按钮,或者你可以鼠标悬停在视觉工作室编辑器中的 YourClass 文本,然后选择空间。

If you're unsure of the namespace of YourClass you can find it within the Class file at the top, directly beneath your using statements. Or you can mouse over the YourClass text in the Visual Studios Editor and then select the namespace by clicking the button that appears.

这篇关于在类库访问方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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