---------------------- Windows Phone 7手机开发、Net培训、期待与您交流! ----------------------
修改密码
string password = textBox1.Text;
string password1 = textBox2.Text;
string password2 = textBox3.Text;
//判断旧密码的输入
if (password != "888888")
{
MessageBox.Show("旧密码输入有误");
return;
}
if (password1 != password2)
{
MessageBox.Show("新密码输入的不一致");
return;
}
if (password == password1 || password == password2)
{
MessageBox.Show("旧密码不能和新密码重复");
return;
}
MessageBox.Show("修改成功");
输出最高成绩
string[] lines = textBox1.Lines;
string maxname = "";
int maxscore = -1;
foreach (string line in lines)
{
string[] strs = line.Split('=');
string name = strs[0];
string strscore = strs[1];
int score = Convert.ToInt32(strscore);
if (score > maxscore)
{
maxname = name;
maxscore = score;
}
MessageBox.Show(string.Format("{0}是第一名成绩{1}",maxname,maxscore));
登陆界面
string username = textBox1.Text.Trim();
string password = textBox2.Text.Trim();
// 不区分大小写,用.Equals 中的方法 忽略大小写
if (username.Equals( "admin", StringComparison.OrdinalIgnoreCase) && password =="888888")
{
MessageBox.Show("欢迎登录");
}
或者 if (username == "admin" && password == "888888")
{
MessageBox.Show("欢迎登录");
}
else
{
if (i >= 3)
{
MessageBox.Show("登录的次数过多,退出程序");
Application.Exit();
}
MessageBox.Show("密码或用户名错误,请重新登录");
计算运算器
string str1 = textBox1.Text;
string str2 = textBox2.Text;
int i1,i2;
if (int.TryParse(str1, out i1) == false)
{
MessageBox.Show("第一个输入错误");
return;
}
if (int.TryParse(str2, out i2) == false)
{
MessageBox.Show("第二个输入错误");
return;
}
int i3 = i2 + i1;
textBox3.Text = Convert.ToString(i3);
四则运算器
string str1 = textBox1.Text;
string str2 = textBox2.Text;
int i1 = Convert.ToInt32(str1);
int i2 = Convert.ToInt32(str2);
int i3;
switch (comboBox1.SelectedIndex)
{
case 0:
i3 = i1 + i2;
break;
case 1:
i3 = i1 - i2;
break;
case 2:
i3 = i1 * i2;
break;
case 3:
if (i2 == 0)
{
MessageBox.Show("除数不能为0");
}
i3 = i1 / i2;
break;
default:
throw new Exception("未知的运算");
}
textBox3.Text = Convert.ToString(i3);
----------------------Windows Phone 7手机开发、Net培训、期待与您交流! ----------------------
详细请查看:http://net.itheima.com/