C#如何封装?
来源:百度知道 编辑:UC知道 时间:2024/05/04 03:22:59
我是想问,能不能不是封装成安装文件,是封装成不要安装的可执行文件? 不要是调试文件夹下的那个。要封装起来,在没.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);