How to check if a string is upper case in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "C# JAVA C++";

            if (IsUpper(s))
                Console.WriteLine("yes");
            else
                Console.WriteLine("no");
        }

        public static bool IsUpper(string s)
        {
            for (int i = 0; i < s.Length; i++)
            {
                if (char.IsLower(s[i]))
                {
                    return false;
                }
            }
            return true;
        }

    }
}


/*
run:
 
yes

*/

 



answered Dec 31, 2016 by avibootz

Related questions

...