【计算机基础】静态方法和非静态方法
目录
非静态方法:
静态方法:static
非静态方法:
public class SQLHelper
{
public int test()//非静态方法
{
return res;
}
}
非静态方调用的时候:
实例化类.方法
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(new SQLHelper().test ());//对非静态方法的调用
}
静态方法:static
public class SQLHelper
{
public static int test()//静态方法
{
return res;
}
}
静态方法调用:
类名.方法
protected void Page_Load(object sender, EventArgs e)
{
Response.Write( SQLHelper.test ());//对静态方法的调用
}
小编先理解到这里,欢迎指正!
还没有评论,来说两句吧...