Один способ с bash (версия 4 +):
foo=bar
echo "${foo^}"
печатает:
Bar
Возможно, вы захотите взглянуть на регулярные выражения. Примерно так:
string inputOk = "Thisisatest";
string inputNok1 = "ThisisaTest";
string inputNok2 = "thisisatest";
bool resultOk = Regex.IsMatch(inputOk, "^[A-Z]{1}[a-z]+$");
bool resultNok1 = Regex.IsMatch(inputNok1, "^[A-Z]{1}[a-z]+$");
bool resultNok2 = Regex.IsMatch(inputNok2, "^[A-Z]{1}[a-z]+$");`
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();
}
}