C#如何封装?

来源:百度知道 编辑:UC知道 时间:2024/05/04 03:22:59
想将一个C#程序封装为一个EXE可执行文件,程序中还引用了一个动态链接库,请问大虾们怎么能实现? 最好弄出来的可执行程序能在没.net环境下也能使用。
我是想问,能不能不是封装成安装文件,是封装成不要安装的可执行文件? 不要是调试文件夹下的那个。要封装起来,在没.net环境下最好能运行的。

/只读封装
public class Department
{
private string department;
public Department(string str)//有参构造函数
{
department = str;
}
public string DepartmentName
{
get { return this.department; }
}

}
public class Tester
{
static void Main(string[] args)
{
Department pm = new Department("myName");
Console.WriteLine("pm.DepartmentName is:{0}", pm.DepartmentName);
Console.Read();
}

//2:只写封装
public class SetPart
{
private string setpart;
public string Setpartname
{
set
{
setpart = value;
Console.WriteLine("the Setpartname is:{0}",setpart);