zoukankan      html  css  js  c++  java
  • [C#]写自己的类库

    类库,就是我们所说的动态链接库(DLL)。在C#中,我们可以把我们做的一些类封装成一个类库,然后把类库模糊化处理,就可以共享给别人用了。

    我们首先新建一个类 比如叫Test类,我们添加一个函数hello函数,返回字符串“test”。

    [csharp] view plaincopy
    1. using System;  
    2. using System.Collections.Generic;  
    3. using System.Linq;  
    4. using System.Text;  
    5.   
    6. namespace Test  
    7. {  
    8.     public class main  
    9.     {  
    10.         public string hello()  
    11.         {  
    12.             return "test";  
    13.         }  
    14.     }  
    15. }  


    然后我们在项目中添加引用,选择Test,添加,OK。

    那么怎么用呢?就象这样:

    [csharp] view plaincopy
      1. Test.main mytest=new Test.main();  
      2. MessageBox.show(mytest.hello());  
  • 相关阅读:
    K
    A
    C
    E
    2020/9/14
    hdu5306 hdu3954 cf438D
    2020/9/10-9/11
    题解
    2020/8/31
    2020/8/30
  • 原文地址:https://www.cnblogs.com/bobo41/p/3054508.html
Copyright © 2011-2022 走看看