Sunteți pe pagina 1din 8

Character |1 I.

INTRODUCTION

The char keyword is used to declare an instance of the System.Char structure that represents a Unicode character. Unicode characters are used to represent most of the written languages throughout the world. Type Range Size .NET Framework type

char

U+0000 to U+ffff

Unicode 16-bit character

System.Char

Table 1.1. Range, Size and .NET Framework type of Character

II.

CHARACTER LITERALS

A character literal represents a single character, and usually consists of a character in quotes, as in 'a'.

character-literal: character:
' character '

single-character simple-escape-sequence hexadecimal-escape-sequence unicode-escape-sequence single-character: Any character except ' (U+0027), \ (U+005C), and new-line-character simple-escape-sequence: one of \' \" \\ \0 \a \b \f \n \r \t \v hexadecimal-escape-sequence: \x hex-digit hex-digitopt hex-digitopt hex-digitopt

A character that follows a backslash character (\) in a character must be one of the following characters: ', ", \, 0, a, b,f, n, r, t, u, U, x, v. Otherwise, a compile-time error occurs. A hexadecimal escape sequence represents a single Unicode character, with the value formed by the hexadecimal number following "\x". If the value represented by a character literal is greater than U+FFFF, a compile-time error occurs.

Character |2 A Unicode character escape sequence in a character literal must be in the range U+0000 to U+FFFF. A simple escape sequence represents a Unicode character encoding, as described in the table below.

Escape sequence \'

Character name Single quote

Unicode encoding 0x0027

\"

Double quote

0x0022

\\

Backslash

0x005C

\0

Null

0x0000

\a

Alert

0x0007

\b

Backspace

0x0008

\f

Form feed

0x000C

\n

New line

0x000A

\r

Carriage return

0x000D

\t

Horizontal tab

0x0009

Character |3

\v

Vertical tab

0x000B

Table 2.1. Escape Sequence of Character The type of a character-literal is char.

III.

METHODS

The Char type exposes the following members. Name CompareTo(Char) Description Compares this instance to a specified Char object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified Char object. Compares this instance to a specified object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified Object. Returns a value that indicates whether this instance is equal to the specified Char object. Returns a value that indicates whether this instance is equal to a specified object. (Overrides ValueType.Equals(Object).) Returns the hash code for this instance. (OverridesValueType.GetHashCode.) Converts the specified numeric Unicode character to a doubleprecision floating point number. Converts the numeric Unicode character at the specified

CompareTo(Object)

Equals(Char)

Equals(Object)

GetHashCode

GetNumericValue(Char)

GetNumericValue(String,

Character |4

Int32)

position in a specified string to a double-precision floating point number. Gets the Type of the current instance. (Inherited from Object.) Returns the TypeCode for value type Char. Categorizes a specified Unicode character into a group identified by one of the UnicodeCategory values. Categorizes the character at the specified position in a specified string into a group identified by one of the UnicodeCategory values. Indicates whether the specified Unicode character is categorized as a control character. Indicates whether the character at the specified position in a specified string is categorized as a control character. Indicates whether the specified Unicode character is categorized as a decimal digit. Indicates whether the character at the specified position in a specified string is categorized as a decimal digit. Indicates whether the specified Char object is a high surrogate. Indicates whether the Char object at the specified position in a string is a high surrogate. Indicates whether the specified Unicode character is categorized as a Unicode letter.

GetType GetTypeCode GetUnicodeCategory(Char)

GetUnicodeCategory(String, Int32)

IsControl(Char)

IsControl(String, Int32)

IsDigit(Char)

IsDigit(String, Int32)

IsHighSurrogate(Char) IsHighSurrogate(String, Int32) IsLetter(Char)

Character |5

IsLetter(String, Int32)

Indicates whether the character at the specified position in a specified string is categorized as a Unicode letter. Indicates whether the specified Unicode character is categorized as a letter or a decimal digit.

IsLetterOrDigit(Char)

IsLetterOrDigit(String, Int32) Indicates whether the character at the specified position in a specified string is categorized as a letter or a decimal digit. IsLower(Char) Indicates whether the specified Unicode character is categorized as a lowercase letter. Indicates whether the character at the specified position in a specified string is categorized as a lowercase letter. Indicates whether the specified Char object is a low surrogate. Indicates whether the Char object at the specified position in a string is a low surrogate. Indicates whether the specified Unicode character is categorized as a number. Indicates whether the character at the specified position in a specified string is categorized as a number. Indicates whether the specified Unicode character is categorized as a punctuation mark. Indicates whether the character at the specified position in a specified string is categorized as a punctuation mark. Indicates whether the specified Unicode character is

IsLower(String, Int32)

IsLowSurrogate(Char) IsLowSurrogate(String, Int32) IsNumber(Char)

IsNumber(String, Int32)

IsPunctuation(Char)

IsPunctuation(String, Int32)

IsSeparator(Char)

Character |6

categorized as a separator character. IsSeparator(String, Int32) Indicates whether the character at the specified position in a specified string is categorized as a separator character. Indicates whether the specified character has a surrogate code point. Indicates whether the character at the specified position in a specified string has a surrogate code point. Indicates whether the two specified Char objects form a surrogate pair. Indicates whether two adjacent Char objects at a specified position in a string form a surrogate pair. Indicates whether the specified Unicode character is categorized as a symbol character. Indicates whether the character at the specified position in a specified string is categorized as a symbol character. Indicates whether the specified Unicode character is categorized as an uppercase letter. Indicates whether the character at the specified position in a specified string is categorized as an uppercase letter. Indicates whether the specified Unicode character is categorized as white space.

IsSurrogate(Char)

IsSurrogate(String, Int32)

IsSurrogatePair(Char, Char)

IsSurrogatePair(String, Int32) IsSymbol(Char)

IsSymbol(String, Int32)

IsUpper(Char)

IsUpper(String, Int32)

IsWhiteSpace(Char)

Character |7

IsWhiteSpace(String, Int32)

Indicates whether the character at the specified position in a specified string is categorized as white space. Creates a shallow copy of the current Object. (Inherited from Object.) Converts the value of the specified string to its equivalent Unicode character. Converts the value of a Unicode character to its lowercase equivalent. Converts the value of a specified Unicode character to its lowercase equivalent using specified culture-specific formatting information. Converts the value of a Unicode character to its lowercase equivalent using the casing rules of the invariant culture. Converts the value of this instance to its equivalent string representation. (Overrides ValueType.ToString.) Converts the specified Unicode character to its equivalent string representation. Converts the value of this instance to its equivalent string representation using the specified culture-specific format information. Converts the value of a Unicode character to its uppercase equivalent.

MemberwiseClone

Parse

ToLower(Char)

ToLower(Char, CultureInfo)

ToLowerInvariant

ToString

ToString(Char)

ToString(IFormatProvider)

ToUpper(Char)

Character |8

ToUpper(Char, CultureInfo)

Converts the value of a specified Unicode character to its uppercase equivalent using specified culture-specific formatting information. Converts the value of a Unicode character to its uppercase equivalent using the casing rules of the invariant culture. Converts the value of the specified string to its equivalent Unicode character. A return code indicates whether the conversion succeeded or failed. Table 3.1 Character Methods

ToUpperInvariant

TryParse

S-ar putea să vă placă și