Also was genau ist das Problem? und vielen Dank im Voraus
Code: Select all
internal class Program
{
public static bool ContainSpaecial(string password)
{
string special = $"!@#$%^&*|/?`~';:()_+-=";
bool contains = password.Contains(special);
return contains;
}
static void Main(string[] args)
{
Console.WriteLine("please enter a password: ");
string password = Console.ReadLine();
string passwordcf;
bool containssymbol = ContainSpaecial(password);
while (password.Length < 8 || containssymbol == false)
{
if (string.IsNullOrEmpty(password))
{
Console.Write("please enter a password: ");
password = Console.ReadLine();
containssymbol = ContainSpaecial(password);
}
else if (password.Length < 8)
{
Console.Write("password is short, please try again: ");
password = Console.ReadLine();
containssymbol = ContainSpaecial(password);
}
else
{
Console.Write("password must contain one symbol at least: ");
password = Console.ReadLine();
containssymbol = ContainSpaecial(password);
}
}
Console.Write("please enter password again to confirm: ");
passwordcf = Console.ReadLine();
while (passwordcf != password)
{
if (!string.IsNullOrEmpty(passwordcf))
{
Console.Write("passwords does not match, please try again: ");
passwordcf = Console.ReadLine();
}
else
{
Console.Write("please enter password again to confirm: ");
passwordcf = Console.ReadLine();
}
}
Console.WriteLine("password created successfully!");
}
}