我試圖做一個簡單的登錄/身份驗證控制檯應用程序,例如我有一個字符串testpwd作爲我的密碼,我想讓程序以毫秒計時用戶開始輸入密碼,並且應該輸出每個用戶每次用戶在鍵盤上使用GetTickCount
函數的幫助開始鍵入時輸入密碼多少秒。使用GetTickCount函數創建身份驗證控制檯應用程序
我不知道我該怎麼去了解它,但我設法做的唯一的事情就是下面這段代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace LoginSystem
{
class LSystem
{
static void Main(string[] args)
{
Console.WriteLine("Hello! This is simple login system!");
Console.Write("Write your username here: ");
string strUsername = Console.ReadLine();
string strTUsername = "testuser";
if (strUsername == strTUsername)
{
Console.Write("Write your password here: ");
Console.ForegroundColor = ConsoleColor.Black;
string strPassword = Console.ReadLine();
string strTPassword = "testpwd";
if (strPassword == strTPassword)
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine("You are logged in!");
Console.ReadLine();
}
else
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine("Bad password for user: {0}", strUsername);
Console.ReadLine();
}
}
else
{
Console.WriteLine("Bad username!");
Console.ReadLine();
}
}
}
}
道具毆打我將它與同樣的答案:-) – theMayer 2013-03-16 15:47:07
使用System.Diagnostics程序,無需引用新assemby。它在System.Dll中 – Steve 2013-03-16 16:26:30