在CreateAccount方法中怎么判断 Initial方法中的_name字段的存不存在
namespace TestRunning{
class TestRunningT
{
static void Main(string[] args)
{
Test_User_Account.Bank chai = new Test_User_Account.Bank();
// chai.CreateAccount();
chai.ShowCustomMenu();
//chai.ShowAllUser();
System.Console.ReadKey();
}
}
}
namespace Test_User_Account
{
/// <summary>
/// 账户类
/// </summary>
public class User
{
public string _name;
public string _identityNum;
public string _password;
public double _balance;
public string _account;
}
///<summary>
///银行类
///</summary>
public class Bank
{
///<summary>
///开户
///</summary>
public void ShowCustomMenu()
{
string option = "";
do
{
System.Console.WriteLine("=============欢迎使用自动银行服务=============");
System.Console.WriteLine("1:存款 2:取款 3:转账 4:查询余额 5:退出");
System.Console.WriteLine("=======================================");
option = System.Console.ReadLine();
switch (option)
{
case "1":
CreateAccount();
continue;
case "2":
continue;
case "3":
case "4":
case "5":
break;
default:
System.Console.WriteLine("[输入无效]");
continue;
}
break;
}while(true);
}
public void CreateAccount()
{
User user = new User();
Initial();
System.Console.WriteLine("请输入账号姓名");
user._name = System.Console.ReadLine();
user._account = "179708064356";
System.Console.WriteLine("请输入账号密码");
user._password = System.Console.ReadLine();
System.Console.WriteLine("请输入账号身份证号:");
user._identityNum = System.Console.ReadLine();
System.Console.WriteLine("请输入账户存款金额");
user._balance = double.Parse(System.Console.ReadLine());
foreach(User a in _userGroup)
{
}
}
User[]_userGroup = new User;//创建了一个类型数组
/// <summary>
/// 初始化数组对象
/// </summary>
public void Initial()
{
_userGroup=new User();//存放对象
_userGroup._account = "179708064356";//对象中的属性或字段的数值化
_userGroup._name = "王丽丽";
_userGroup._password = "123456";
_userGroup._identityNum = "210025019589750";
_userGroup._balance = 1000;
_userGroup = new User();
_userGroup._account = "179708064356";
_userGroup._name = "张茵茵";
_userGroup._password = "123456";
_userGroup._identityNum = "210025019589750";
_userGroup._balance = 2000;
_userGroup = new User();
_userGroup._account = "179708064356";
_userGroup._name = "刘华";
_userGroup._password = "123456";
_userGroup._identityNum = "210025019589750";
_userGroup._balance = 100;
}
public void ShowAllUser()
{
Initial();
foreach(User useritem in _userGroup)
{
System.Console.WriteLine("账号姓名:"+useritem._name);
}
}
}
}
路过 ifname != null || name!="" 惜鑫 发表于 2014-7-29 19:48
ifname != null || name!=""
不行吧 如果我输入不是那里面的账户那我岂不是也能够登陆进去啊
页:
[1]