Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# user and password verification

static List<KeyValuePair<string, string>> UsersAndPasswords = new List<KeyValuePair<string, string>>();
        static void Main(string[] args)
        {
            AddUser("Cat", "mecat");
            Console.Write("User Name: ");
            string? InputetedUserName = Console.ReadLine();
            Console.Write("
Password: ");
            string? InputetedPass = Console.ReadLine();
            bool foundUser = false;
            bool isAccessVerified = false;
            for (int i = 0; i < UsersAndPasswords.Count; i++)
            {
                if (UsersAndPasswords[i].Key == InputetedUserName)
                {
                    foundUser = true;
                    if (UsersAndPasswords[i].Value == InputetedPass)
                    {
                        Console.WriteLine("Access Verified.");
                        isAccessVerified = true;
                    }
                    else
                    {
                        Console.WriteLine("Password is incorrect.");
                    }
                    break;
                }
            }
            if (!foundUser)
                Console.WriteLine("User not found.");
            if (isAccessVerified)
            {
                //continue code...
            }
        }

        private static void AddUser(string username, string password)
        {
            UsersAndPasswords.Add(new KeyValuePair<string, string>(username,password));
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# monogame docs 
Csharp :: what error code i should return in asp.net core whether user name or password are incorrect 
Csharp :: scroll two divs simultaneously site:stackoverflow.com 
Csharp :: call a .NET assembly from C or c++ 
Csharp :: C++ program obtein volume in windows 
Csharp :: c# create monochrome bitmap 
Csharp :: c# convert timestamp to datetime 
Csharp :: unity check if swipe not tap 
Csharp :: dictionary and generic class c# 
Csharp :: get innermost exception c# 
Csharp :: c# deeply related children 
Csharp :: Console.WriteLine($"Hello {Ana.ToUpper($)}!"); 
Csharp :: cmd.executenonquery() error in c# 
Csharp :: OBSERVER 
Csharp :: Using a Views in .net and c# 
Csharp :: VideoPlayer.isPlaying 
Csharp :: open and close autocad api 
Csharp :: c# console.writeline next line 
Csharp :: linq contains null 
Csharp :: what loops are entry controlled c# 
Csharp :: initialize c# array property of class object site:stackoverflow.com 
Csharp :: .net check connection 
Csharp :: @using System,System.Core 
Csharp :: ms transform 
Csharp :: c# write to registry hkey_current_user 
Csharp :: attribute decorator to require email format of string c# 
Csharp :: c# convert 1 to 01 
Csharp :: c# boolean 
Csharp :: lexicographically sorted 
Csharp :: create shortcut C# WPF 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =