using System;
using System.Collections.Generic;
namespace RegistrationLogin
{
class Program
{
static List< User> users = new List< User>();
static void Main(string[] args)
{
Console.WriteLine("Select an option:");
Console.WriteLine("1. Register");
Console.WriteLine("2. Login");
Console.Write("Enter your choice: ");
int choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
Register();
break;
case 2:
Login();
break;
default:
Console.WriteLine("Invalid option. Try again.");
break;
}
Console.ReadLine();
}
static void Register()
{
Console.Write("Enter your username: ");
string username = Console.ReadLine();
Console.Write("Enter your password: ");
string password = Console.ReadLine();
User user = new User(username, password);
users.Add(user);
Console.WriteLine("Registration successful.");
}
static void Login()
{
Console.Write("Enter your username: ");
string username = Console.ReadLine();
Console.Write("Enter your password: ");
string password = Console.ReadLine();
foreach (User user in users)
{
if (user.Username == username && user.Password == password)
{
Console.WriteLine("Login successful.");
return;
}
}
Console.WriteLine("Login failed.");
}
}
class User
{
public string Username { get; set; }
public string Password { get; set; }
public User(string username, string password)
{
this.Username = username;
this.Password = password;
}
}
}