与类有关几点疑惑?熟手能解释下吗?
public class a{
protected string name;
protected string pass;
public string Name{
get{return name;}
set{name = value;}
}
public string Pass{
get{return pass;}
set{pass = value;}
}
方法一:
public chk(string name,string pass){
strSql = "select uName,uPass form User where uName = @name and uPass =@pass ";
cmd.Sqlparameters.[ "@name "].Value=name;
cmd.Sqlparameters.[ "@pass "].Value=pass;
cdm.ExecuteScalar();
}
方法二:
public chkLog(string name,string pass){
strSql = "select uName,uPass form User where uName = @name and uPass =@pass ";
cmd.Sqlparameters.[ "@name "].Value=name;
cmd.Sqlparameters.[ "@pass "].Value=pass;
cdm.ExecuteScalar();
}
}
在实例化引用这两方法的时候有几个地方不明
比如: a A = new a();
A.Name = TextBox1.Text;
A.Pass = TextBox2.Text;
A.chk();
引用方法二:
a A = new a();
string name = TextBox1.Text;
string pass = TextBox2.Text;
A.chk(name,pass);
这两种方式引用都可以,第二种方式感觉根本就不用要什么字段,属性,在编写类的时候到底需不需要属性这些呢,那种方式比较好??
------解决方案--------------------帮顶,学习中.
------解决方案--------------------public chk()
???
这是什么呀
怎么都没有返回啊