Char.IsControl Method (Char)
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Indicates whether the specified Unicode character is categorized as a control character.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Shared Function IsControl ( _
c As Char _
) As Boolean
public static bool IsControl(
char c
)
Parameters
- c
Type: System.Char
A Unicode character.
Return Value
Type: System.Boolean
true if c is a control character; otherwise, false.
Remarks
Control characters are non-printing and formatting characters, such as ACK, BEL, CR, FF, LF, and VT. The Unicode standard assigns the following code points to control characters: from \U0000 to \U001F, \U007F, and from \U0080 to \U009F. According to the Unicode standard, these values are to be interpreted as control characters unless their use is otherwise defined by an application. Valid control characters are members of the UnicodeCategory.Control category.
Examples
The following example lists the Unicode code point of each of the control characters.
Module Example
Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
Dim charsWritten As Integer = 0
For ctr As Integer = &H0 To &HFFFF
Dim ch As Char = Convert.ToChar(ctr)
If Char.IsControl(ch) Then
outputBlock.Text += String.Format("\U{0:X4} ", ctr)
charsWritten += 1
If (charsWritten Mod 6) = 0 Then
outputBlock.Text &= vbCrLf
End If
End If
Next
End Sub
End Module
' The example displays the following output:
' \U0000 \U0001 \U0002 \U0003 \U0004 \U0005
' \U0006 \U0007 \U0008 \U0009 \U000A \U000B
' \U000C \U000D \U000E \U000F \U0010 \U0011
' \U0012 \U0013 \U0014 \U0015 \U0016 \U0017
' \U0018 \U0019 \U001A \U001B \U001C \U001D
' \U001E \U001F \U007F \U0080 \U0081 \U0082
' \U0083 \U0084 \U0085 \U0086 \U0087 \U0088
' \U0089 \U008A \U008B \U008C \U008D \U008E
' \U008F \U0090 \U0091 \U0092 \U0093 \U0094
' \U0095 \U0096 \U0097 \U0098 \U0099 \U009A
' \U009B \U009C \U009D \U009E \U009F
using System;
public class Example
{
public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
int charsWritten = 0;
for (int ctr = 0x00; ctr <= 0xFFFF; ctr++)
{
char ch = Convert.ToChar(ctr);
if (char.IsControl(ch))
{
outputBlock.Text += String.Format(@"\U{0:X4} ", ctr);
charsWritten++;
if (charsWritten % 6 == 0)
outputBlock.Text += "\n";
}
}
}
}
// The example displays the following output:
// \U0000 \U0001 \U0002 \U0003 \U0004 \U0005
// \U0006 \U0007 \U0008 \U0009 \U000A \U000B
// \U000C \U000D \U000E \U000F \U0010 \U0011
// \U0012 \U0013 \U0014 \U0015 \U0016 \U0017
// \U0018 \U0019 \U001A \U001B \U001C \U001D
// \U001E \U001F \U007F \U0080 \U0081 \U0082
// \U0083 \U0084 \U0085 \U0086 \U0087 \U0088
// \U0089 \U008A \U008B \U008C \U008D \U008E
// \U008F \U0090 \U0091 \U0092 \U0093 \U0094
// \U0095 \U0096 \U0097 \U0098 \U0099 \U009A
// \U009B \U009C \U009D \U009E \U009F
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.