Q:

Write a C# Sharp program to check if a given string contains only lowercase or uppercase characters

0

Write a C# Sharp program to check if a given string contains only lowercase or uppercase characters

Sample Output:

True
True
False

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Linq;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(test("PHP"));
            Console.WriteLine(test("python"));
            Console.WriteLine(test("JavaScript"));
        }
        public static bool test(string str1)
        {
            return str1 == str1.ToUpper() | str1 == str1.ToLower();
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now