Professional Documents
Culture Documents
C Training Day 5
C Training Day 5
• IsLetterOrDigit() • MinValue
• IsWhiteSpace() • MaxValue
• IsDigit()
• IsLetter()
• IsUpper()
• IsLower()
• ToUpper()
• ToLower()
Constant of char
MaxValue: It is a constant field which represents the largest possible value of a Char.
Example:
Console.WriteLine(char.MaxValue);
MinValue: It is a constant field which represents the smallest possible value of a Char.
Example:
Console.WriteLine(char.MinValue);
Methods of char
IsLetterOrDigit()
Indicates whether a Unicode character is categorized as a letter or a decimal digit.
Syntax:
public static bool IsLetterOrDigit(char ch);
Parameter:
ch: It is required Unicode character of System.char type which is to be checked.
Return Type: The method returns True, if it successfully matches any Unicode letter or decimal digit, otherwise
returns False. The return type of this method is System.Boolean.
Example:
bool result; // checking if G is a // letter or decimal digit char ch1 = 'G'; result = Char.IsLetterOrDigit(ch1);
Console.WriteLine(result); // checking if '@' is a // letter or decimal digitchar ch2 = '@';
result = Char.IsLetterOrDigit(ch2); Console.WriteLine(result);
Methods of char
IsWhiteSpace()
Indicates whether a Unicode character is categorized as white space.
Syntax: public static bool IsWhiteSpace(char ch);
Parameter:
ch: It is required Unicode character of System.char type which is to be checked for whitespace.
Return Type : The method returns True if the specified Unicode character is a whitespace character, otherwise
returns False. The return type of this method is System.Boolean.
Example: // checking if space is a whitespace
bool result; char ch1 = ' '; result = Char.IsWhiteSpace(ch1); Console.WriteLine(result);
// checking if hyphen is a whitespace
char ch3 = '-';
result = Char.IsWhiteSpace(ch3);
Console.WriteLine(result);
Methods of char
IsDigit()
Indicates whether a Unicode character is categorized as a decimal digit.
Syntax: public static bool IsDigit(char ch);
Parameter:
ch: It is required Unicode character of System.char type which is to be checked.
Return Type: The method returns True, if it successfully matches any decimal digit, otherwise returns False. The
return type of this method is System.Boolean.
Example: bool result;
// checking if 5 is a digit or not
char ch1 = '5'; result = Char.IsDigit(ch1); Console.WriteLine(result);
// checking if 'c' is a digit
char ch2 = 'c'; result = Char.IsDigit(ch2);
Console.WriteLine(result);
Methods of char
IsLetter()
Indicates whether a Unicode character is categorized as a Unicode letter.
Syntax: public static bool IsLetter(char ch);
Parameter:
ch: It is required Unicode character of System.char type which is to be checked.
Return Type: The method returns True, if it successfully matches any Unicode letter, otherwise returns False. The
return type of this method is System.Boolean.
Example: bool result;
// checking if G is a Unicode letter or not
char ch1 = 'G'; result = Char.IsLetter(ch1); Console.WriteLine(result);
// checking if '6' is a Unicode letter or not
char ch2 = '6';
result = Char.IsLetter(ch2);
Console.WriteLine(result);
Methods of char
IsUpper()
Indicates whether a Unicode character is categorized as an uppercase letter.
Syntax: public static bool IsUpper(char ch);
Parameter:
ch: It is required Unicode character of System.char type which is to be checked.
Return Type: The method returns True, if it successfully matches any uppercase letter, otherwise returns False.
The return type of this method is System.Boolean.
Example:bool result;
// checking if G is a uppercase letter or not
char ch1 = 'G'; result = Char.IsUpper(ch1);Console.WriteLine(result);
// checking if 'g' is a uppercase letter or not
char ch2 = 'g';
result = Char.IsUpper(ch2);
Console.WriteLine(result);
Methods of char
IsLower()
Indicates whether a Unicode character is categorized as a lowercase letter.
Syntax: public static bool IsLower(char ch);
Parameter:
ch: It is required Unicode character of System.char type which is to be checked.
Return Type: The method returns True, if it successfully matches any lowercase letter, otherwise returns False.
The return type of this method is System.Boolean.
Example: bool result;
// checking if G is a lowercase letter or not
char ch1 = 'G'; result = Char.IsLower(ch1);Console.WriteLine(result);
// checking if 'g' is a lowercase letter or not
char ch2 = 'g';
result = Char.IsLower(ch2);
Methods of char
ToUpper()
Converts the value of a Unicode character to its uppercase equivalent.
Example:
char ch = 'd';
char ch1 = char.ToUpper(ch);
ToLower()
Converts the value of a Unicode character to its lowercase equivalent.
char ch = 'D';
char ch1 = char.ToLower(ch);
PROGRAMS TO PRACTICE