1. Home
  2. Computing & Technology
  3. C / C++ / C#

C# Programming Tutorial - About Strings and Chars

By , About.com Guide

7 of 10

More String Functions and Methods

An example of ToUpper.
string AboutStr = "About C, C++ and C#";
string ucAboutStr = AboutStr.ToUpper() ;
Console.WriteLine("AboutStr, ucAboutStr=\n\r{0}\n\r{1}",AboutStr,ucAboutStr) ;
This produces:
AboutStr, ucAboutStr=
About C, C++ and C#
ABOUT C, C++ AND C#

Need a Trim?

C# provides one trim method to trim white spaces from both the start and end of a string and trimstart and trimend for each end of a string. For most developers, white space means the 0x9 (tab) and 0x20 (i.e. the space ' ' char). However unicode whitespace has a few more characters including 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x0085, 0x2028, and 0x2029. To simplify this, the function isWhiteSpace(char x) is provided. Use it like this
char ch = 'T';
if (char.IsWhiteSpace(ch)) then
  {
The Char class provides a number of static classification functions, most with two overloads like this:
  1. IsFunction(Char) - check the Char
  2. IsFunction(String, Int32) - Check the indexed Char
I've broken these into groups.
  • IsControl - Is the character a control character?
  • IsDigit - Is the character a decimal digit?
  • IsLetter - Is the character an alphabetic letter?
  • IsLetterOrDigit - Is the character an alphabetic letter or a decimal digit?
  • IsNumber - Is the character a number?
  • IsPunctuation - Is the character a punctuation mark?
  • IsSeparator - Is the character a separator character?
  • IsSymbol - Is the character a symbol character?
  • IsWhiteSpace - Is the character a white space?
  • IsLower - Is the character a lowercase letter?
  • IsUpper - Is the character an uppercase letter?
  • IsLowSurrogate - Is the Char object a low surrogate?
  • IsSurrogate - Is the character a surrogate character.?
  • IsSurrogatePair - Are the two Char objects a surrogate pair?
  • IsHighSurrogate - Is the Char object a high surrogate?

On the next page - Some More String Functions and Methods

Explore C / C++ / C#
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
  4. C# / C Sharp
  5. Learn C Sharp
  6. More String Functions and Methods

©2009 About.com, a part of The New York Times Company.

All rights reserved.