这次继续这个系列的介绍:
** 一、** 命名空间的起名;
对于C#来说,一般命名空间的建议是:公司名(或个人名称).产品名.分类名,比如我这边是用的这个:Lzhdim.LPF.Helper,意思是个人名Lzhdim,加上LPF为平台名,加上Helper分类为帮助类,其它的更长的请读者自己添加。

** 二、** Dll库里的内容;
下面介绍Dll库里的代码内容:
- 静态类;一些函数方法
最常见的库里的内容就是静态类了,这些类提供了一些读者封装的函数,主要以提供函数为主。使用方法也很简单,先声明命名空间,然后直接输入静态类名,用点号,然后就会显示该静态里里的函数了。

比如这里新建了一个Helper库,然后添加分类目录StaticDll,然后新建一个类,命名为StaticDllHelper。


然后,在静态类里添加代码:

这里新建了一个静态类,命名为StaticDllHelper,还定义了一个静态函数TestDllHelper,注意这里添加了static 声明该函数为静态函数。
- 动态类;一些对象
动态类一般为类定义,为对象的模板。笔者这里的建议是,一般动态类直接定义对象,只声明属性,至于该对象的操作,放到静态类里去进行。当然这个是笔者的建议,对于动态类,具有类的特性,一般为封装、继承、多态。下面为一个对象的模板,参考前面新建一个Lzhdim.CharpDll.Module类库,然后添加动态类AppConfigModule:


这里有个例子:
1) 引用该Module库;

2) 声明命名空间;
在顶部using声明该库。

3) 使用该Moudle库;
在上面的例子里,在静态库里的函数中使用该Moudle并进行操作。
下面就用New了一个对象,这里能够直接设置该对象里属性的值。

- 窗体;自定义的窗体
在类库中,还有一种就是类库里定义的窗体。这里也好理解,就是在类库中定义窗体,然后在其它库或应用里进行调用。只需要声明命名空间,然后就能够New一个窗体进行操作了。

注意这里需要引用System.Drawing和System.Windows.Forms这两个库。


这里调用该窗体。
1) 只能在EXE应用类里进行调用;

2) 需要New一个窗体;
声明命名空间;New窗体,然后显示。
