PART II
C h a p t e r 2 1 :
E x p l o r i n g t h e S y s t e m N a m e s p a c e
635
values are used to represent it. The first character is called the
high surrogate
and the second
is called the
low surrogate.
In UTF-32, each code point uses one 32-bit value.
Char
provides
the necessary conversions between UTF-16 and UTF-32.
Char
defines the following fields:
public const char MaxValue
public const char MinValue
These represent the largest and smallest values that a
char
variable can hold.
Char
implements the following interfaces:
IComparable
,
IComparable
,
IConvertible
, and
IEquatable
.
Field
Meaning
public static readonly decimal MaxValue
The largest value that a
decimal
can hold.
public static readonly decimal MinusOne
The
decimal
representation of –1.
public static readonly decimal MinValue
The smallest value that a
decimal
can hold.
public static readonly decimal One
The
decimal
representation of 1.
public static readonly decimal Zero
The
decimal
representation of 0.
T
ABLE
21-8
Fields Suppor ted by
Decimal
Method
Meaning
public int CompareTo(char
v
)
Compares the character in the invoking object
with that of
v.
Returns zero if the characters are
equal. Returns a negative value if the invoking
object has a lower value. Returns a positive value
if the invoking object has a greater value.
public int CompareTo(object
v
)
Compares the character in the invoking object
with that of
v.
Returns zero if the characters are
equal. Returns a negative value if the invoking
object has a lower value. Returns a positive value
if the invoking object has a greater value.
public static string
Conver tFromUtf32(int
utf32Ch
)
Conver ts the Unicode UTF-32 code point in
utf32Ch
into a UTF-16 string and returns the
result.
pubic static int
Conver tToUtf32(char
highSurrogate
,
char
lowSurrogate
)
Conver ts the high and low UTF-16 surrogates
specified by
highSurrogate
and
lowSurrogate
into
a UTF-32 code point. The result is returned.
pubic static int
Conver tToUtf32(string str, int
idx
)
Conver ts the UTF-16 surrogate pair at
str
[
idx
] into
its UTF-32 code point. The result is returned.
public bool Equals(char
v
)
Returns true if the value of the invoking object
equals the value of
v.
public override bool Equals(object
v
)
Returns true if the value of the invoking object
equals the value of
v.
T
ABLE
21-9
Methods Defi ned by
Char
www.freepdf-books.com
636
P a r t I I :
E x p l o r i n g t h e C # L i b r a r y
public override int GetHashCode( )
Returns the hash code for the invoking object.
public static double GetNumericValue(char
ch
)
Returns the numeric value of
ch
if
ch
is a digit.
Other wise, returns –1.
public static double
GetNumericValue(string
str
, int
idx
)
Returns the numeric value of
str
[
idx
] if that
character is a digit. Other wise, returns –1.
public TypeCode GetTypeCode( )
Returns the
TypeCode
enumeration value for
Char
, which is
TypeCode.Char
.
public static UnicodeCategor y
GetUnicodeCategor y(char
ch
)
Returns the
UnicodeCategory
enumeration value
for
ch.
UnicodeCategory
is an enumeration
defined by
System.Globalization
that categorizes
Unicode characters.
public static UnicodeCategor y
GetUnicodeCategor y(string
str
, int
idx
)
Returns the
UnicodeCategory
enumeration value
for
str
[
idx
].
UnicodeCategory
is an enumeration
defined by
System.Globalization
that categorizes
Unicode characters.
public static bool IsControl(char
ch
)
Returns true if
ch
is a control character.
Other wise, returns false.
public static bool IsControl(string
str
, int
idx
)
Returns true if
str
[
idx
] is a control character.
Other wise, returns false.
public static bool IsDigit(char
ch
)
Returns true if
ch
is a digit. Other wise, returns
false.
public static bool IsDigit(string
str
, int
idx
)
Returns true if
str
[
idx
] is a digit. Other wise,
returns false.
public static bool IsHighSurrogate(char
ch
)
Returns true if
ch
is a valid UTF-32 high
surrogate. Other wise, returns false.
public static bool IsHighSurrogate(string
str
,
int
idx
)
Returns true if
str
[
idx
] is a valid UTF-32 high
surrogate. Other wise, returns false.
public static bool IsLetter(char
ch
)
Returns true if
ch
is a letter of the alphabet.
Other wise, returns false.
public static bool IsLetter(string
str
, int
idx
)
Returns true if
str
[
idx
] is a letter of the alphabet.
Other wise, returns false.
public static bool IsLetterOrDigit(char
ch
)
Returns true if
ch
is either a letter of the alphabet
or a digit. Other wise, returns false.
public static bool
IsLetterOrDigit(string
str
, int
idx
)
Returns true if
str
[
idx
] is either a letter of the
alphabet or a digit. Other wise, returns false.
public static bool IsLower(char
ch
)
Returns true if
ch
is a lowercase letter of the
alphabet. Other wise, returns false.
public static bool IsLower(string
str
, int
idx
)
Returns true if
str
[
idx
] is a lowercase letter of the
alphabet. Other wise, returns false.
T
ABLE
21-9
Methods Defi ned by
Char
(continued)
Method
Meaning
www.freepdf-books.com
Do'stlaringiz bilan baham: |