标签:
activator类,用以在本地或从远程创建对象类型,或获取对现有远程对象的引用。 此类不能被继承。下面简单测试其CreateInstance()方法,以便对此类的使用加深理解!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Webtest
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TeaCher tc = (TeaCher)Activator.CreateInstance(typeof(TeaCher));
this.TextBox1.Text = tc.Name;
}
}
public class TeaCher
{
private string name = "哈格";
public string Name
{
get { return name; }
set { name = value; }
}
}
}
标签:
原文地址:http://www.cnblogs.com/hzgxg/p/4685393.html