Synchronization of old projects
Part1
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
namespace Lesson
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static bool Login(string name, string password, ref string info )
|
||||
{
|
||||
string rightUserName = "admin";
|
||||
string rightPassword = "admin123";
|
||||
if (name == rightUserName && password == rightPassword)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (name == rightUserName && password != rightPassword )
|
||||
{
|
||||
info = "密码错误";
|
||||
return false;
|
||||
}
|
||||
else if (name != rightUserName && password == rightPassword)
|
||||
{
|
||||
info = "账号错误";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = "全错全错!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string inputUserName, inputPassword;
|
||||
Console.Write("请输入用户名:");
|
||||
inputUserName = Console.ReadLine();
|
||||
Console.Write("请输入密码:");
|
||||
inputPassword = Console.ReadLine();
|
||||
string info = "";
|
||||
bool access = Login(inputUserName,inputPassword,ref info);
|
||||
if (access)
|
||||
{
|
||||
Console.WriteLine("登录成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("登录失败"+ '\n' + info);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user