bool Success;
do
{
Console.WriteLine("이름을 입력해주세요. (3~10글자)");
string input = Console.ReadLine();
if (input.Length >= 3 && input.Length <= 10)
{
Console.WriteLine("안녕하세요! 제 이름은 " + input + " 입니다.");
}
else
{
Console.WriteLine("이름을 확인해주세요.");
Console.Clear();
}
Success = input.Length >= 3 && input.Length <= 10;
}
while (Success);
보통 닉네임을 만들때 보이는 기능이다.
//Console.WriteLine("이름을 입력해주세요. (3~10글자)");
//string input = Console.ReadLine();
//if (input.Length >= 3 && input.Length <= 10)
//{
// Console.WriteLine("안녕하세요! 제 이름은 " + input + " 입니다.");
//}
//else
//{
// if (input.Length > 10)
// {
// Console.Clear();
// Console.WriteLine("이름을 확인해주세요");
// }
// else if (input.Length < 3)
// {
// Console.Clear();
// Console.WriteLine("이름을 확인해주세요");
// }
//}