日期:2014-05-18 浏览次数:20501 次
//属性用法一
public class CustomnerType
{
private string strCustomerType;
public string CustomerTypeName
{
get
{
return strCustomerType;
}
set
{
strCustomerType= value;
}
}
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CustomnerType objCustomner= new CustomnerType();
txtCustomnerType.Text = objCustomner.CustomerTypeName;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
CustomnerType objCustomner= new CustomnerType();
string CustomerTypeName = txtCustomerTypeName;
objCustomner.CustomerTypeName = CustomerTypeName;
}
}
//大家说看看这样用法有必要吗?有必要的话,有什么好处
//属性讨论二,也是让我疑问最大的用法public class SqlAction
{
private DataSet objSet;
}
public DataTable GetTable // 提供一个可供利用的数据源
{
get
{
return objSet.Tables[0];
}
}
如需要阅读该回复,请登录或注册CSDN!