输入必须为大写(首字母)和小写(其他)

问题描述:

我需要一些帮助来创建一个程序,该程序要求在 UPPER 情况下输入首字母,在 lower 情况下输入所有其他字母.

I need some help creating a program that requires input with first letter in UPPER case and all other in lower case.

我认为你们中有些人不了解这个问题.我必须创建一个循环,要求用户从上至下输入第一个数字,如果不满足要求,则用户必须再次输入,直到第一个字母在上而其他字母在下.>

I think some of u didnt understand the problem. I have to create a loop that requires from the user to enter the first number in upper and others in lower, if the requirements are not met, the user must input once again, until the first letter is upper and others are lower.

var novaDrzava = new Država ();
Console.Write ("Vnesite ime (prva začetnica naj bo velika, ostale male): ");

novaDrzava.Ime = Console.ReadLine ();

var drzava = novaDrzava.Ime;
var inicialka = drzava.Substring (0);
var ostale = drzava.Substring (1, drzava.Length - 1);

for (int i = 0; i <= malecrke.Length; i++) {
    if (inicialka.Contains (velikecrke[i])) {
        if (ostale.Contains (malecrke[i])) {
            break;
        } else {
            Console.WriteLine ("Ponovno vnesite ime");
            novaDrzava.Ime = Console.ReadLine ();
        }
    }
}

static void Main(string[] args)
        {
            string inputValue = Console.ReadLine();

            bool isValid = true;
            foreach (char val in inputValue)
            {
                if (inputValue.First()==val && char.IsUpper(val))
                {
                  //do nothing.
                }
                else if(char.IsLower(val))
                {
                    // do nothing.
                }
                else
                {
                    isValid = false;
                    Console.WriteLine("Invalid input string");
                    Console.ReadLine();
                    break;
                }
            }

            if (isValid)
            {
                Console.WriteLine("Valid input string");
                Console.ReadLine();
            }

        }