Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# check if username and password is true

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 :: remotefx 3d video adapter warning 
Csharp :: you have the following c# code. stringbuilder sb = new stringbuilder(really long string); the really long string variable is a string in which a very long string is stored. 
Csharp :: viewsheet location revit api 
Csharp :: 7485438 
Csharp :: C# Associativity of Operators 
Csharp :: openiddect ef core table not creating 
Csharp :: gridview column cell alignment form c# 
Csharp :: PUN 2 Network Transform View Jittery Movement 
Csharp :: how to destroy bridges animal crossing 
Csharp :: unity torque distance joint 
Csharp :: itext7 c# memorystream 
Csharp :: xamarin forms set the grid row property of an element programmatically 
Csharp :: c# text editor 
Csharp :: linq conditionnally add where clause 
Csharp :: dotnet core ef add multiple records 
Csharp :: Options Pattern how to use 
Csharp :: dotnet target specific framework 
Csharp :: split string by 5 characters c# 
Csharp :: DisplayUnitType revit 2022 
Csharp :: player leaning unity 
Csharp :: aquarette 
Csharp :: mac osx enable hidpi terminal 
Csharp :: orderby make sunday last day c# 
Csharp :: unity predicts rigidbody position in x seconds 
Csharp :: create viewport revit api 
Csharp :: game creator change local variable 
Csharp :: c# join array 
Csharp :: unity reload script assemblies 
Csharp :: c# exists in list 
Csharp :: c# download file from url 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =