To check if a character is Uppercase in C# and VB.NET you can use the following Extension Method

Sample C#

/// <summary>
///     Checks whether the character is an uppercase Character or not
/// </summary>
/// <param name="inputChar"></param>
/// <returns>True or False depending on the character</returns>
public static bool IsUpperCase(this char inputChar)
{
	return inputChar >= 'A' && inputChar <= 'Z';
}

Sample VB.NET

''' <summary>
'''     Checks whether the character is an uppercase Character or not
''' </summary>
''' <param name="inputChar"></param>
''' <returns>True or False depending on the character</returns>
<System.Runtime.CompilerServices.Extension> _
Public Shared Function IsUpperCase(inputChar As Char) As Boolean
	Return inputChar >= "A"C AndAlso inputChar <= "Z"C
End Function




2 thought on “How to check if a character is Uppercase in C# and VB.NET”

Leave a Reply