C#中编译生成的类库,在引用的时候每个类,枚举、结构体、接口生成各自的文件
比如在类库CustomLib的DataService.cs文件中添加
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CustomLib
{
public enum BoolTF:int
{
False=0,
True=1
}
public enum Color
{
Red=1,
Green=2,
Blue=3
}
public struct Student
{
public string Name;
public int Age;
}
public class DataService
{
public static void ShowMessage()
{
Console.WriteLine("Dataservice");
}
}
public interface IPeople
{
void Work();
void Move();
}
}
编译该类库
新建控制台程序在代码中引用以上的类库CustomLib.dll,访问里面的类,接口,结构体,枚举
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CustomLib;
namespace ConTest
{
//public enum PlayLevels
//{
// // [LocalDescriptor="tick"]
// Tick=0,
// //[LocalDescriptor="收盘价"]
// BarClose=1,
// //[LocalDescriptor="高开低收HOLC"]
// BarHolc=2
//}
class Sample
{
public static void Main(string[] args)
{
DataService.ShowMessage();
int n=(int)BoolTF.False;
Color red = Color.Red;
Student s = new Student();
s.Name="甘全福";
s.Age = 23;
IPeople people;
people.Move();
people.Work();
Console.Read();
}
}
}
在各个类型中按下F12转定义到相应的文件如下
#region 程序集 CustomLib.dll, v4.0.30319
// C:\Users\ganquanfu\Desktop\bin\CustomLib.dll
#endregion
using System;
namespace CustomLib
{
public class DataService
{
public DataService();
public static void ShowMessage();
}
}
其它的转定义方法一个样,这里就不一一列出来了
查找该代码文件会发现,会得到各个单一的文件比如:
CustomLib.BoolTF.cs
CustomLib.DataService.cs
CustomLib.Student.cs
CustomLib.IPeople.cs