110,536
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
int a = 100; //原来的值,或者是由某种条件下计算出来的值.
Account(50, 50, ref a); //执行变更
// a=100 条件达不到,所有不变会
Account(200, 200, ref a); //执行变更
// a=200 达到条件,变更面积
}
public static void Account(int w, int h, ref int a)
{
if (w > 100 && h > 100)
{
a = w * h;
}
}
public bool UserLogin(string UserName,string Pwd,out string Info)
{
if(UserName==null || UserName.Trim()=="")
{
Info="用户名不能为空.";
return false;
}
if(UserName=="a" && Pwd=="b")
{
Info="成功验证.";
return true;
}
else
{
Info="用户名或密码出错.";
return false;
}
}
调用:
string msg;
bool login=UserLogin("a","b",out msg);
if(login)
{
//登陆代码
}
else
{
//弹出错误: msg
Message.Show(msg) //Winfrom
}