String - IsControl

Indicates whether the character at the specified position in a specified string is categorized as a control character.

Try it

public static void Main()
{
    string input = "EF\nEF6\n\r";

    Console.WriteLine("{0}:\t{1}", "Index", "Is Control");

    for (int i = 0; i < input.Length; i++)
    {
		// C# Extension Method: String - IsControl
		var result = input.IsControl(i);
		
        Console.WriteLine("{0}:\t\t{1}", i, result);
    }
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     Indicates whether the character at the specified position in a specified string is categorized as a control
    ///     character.
    /// </summary>
    /// <param name="s">A string.</param>
    /// <param name="index">The position of the character to evaluate in .</param>
    /// <returns>true if the character at position  in  is a control character; otherwise, false.</returns>
    public static Boolean IsControl(this String s, Int32 index)
    {
        return Char.IsControl(s, index);
    }
}