如何在类库中调用函数 [英] how to call a function in classlibrary

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

问题描述

如何在classlibrary中调用函数

how to call a function in classlibrary

推荐答案

您需要执行以下操作:

1)在您的主项目中引用类库.
2)创建所需类型的对象.
2'')如果是静态类,则不需要上面的内容.
3)调用您需要的方法.

You need to do the following :

1) Reference the class library in your main project.
2) create an object of the type you need.
2'') in case of static classes you don''t need the above.
3) call the method you need.

public class classlib
{
   public void Method1()
   {
   }
   
   public static void Method2()
   {
   }
}

public class Main()
{
    classlib myClass = new classlib();
    
    myClass.Method1(); // call normal


    classlib.Method2(); // static method call
    

}



看到此链接: http://www.homeandlearn.co.uk/csharp/csharp_s16p1.html
Hi,
see this link :http://www.homeandlearn.co.uk/csharp/csharp_s16p1.html


这篇关于如何在类库中调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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