Determining If A Character Is Within A Specified Range

using System;
using System.Data;
using System.Text.RegularExpressions;
using System.Text;
class Class1{
static void Main(string[] args){
Console.WriteLine(IsInRange('c', 'a', 'G'));
Console.WriteLine(IsInRange('c', 'a', 'g'));
Console.WriteLine(IsInRange('c', 'c', 'g'));
Console.WriteLine(IsInRange((char)32, 'a', 'b'));
}
public static bool IsInRange(char testChar, char startOfRange, char endOfRange)
{
if (testChar >= startOfRange && testChar <= endOfRange) { // testChar is within the range return (true); } else { // testChar is NOT within the range return (false); } } } [/csharp]

This entry was posted in Data Types. Bookmark the permalink.