String Jargon in C#


Description 

The following article shows some String functions which are not currently available directly in C#.
 
PCase
 
This will conver the string passed to ProperCase ie each word's first is changed to UpperCase().The word is identified using whitespace character such as " ","\t","\n","\r".

Usage: PCase(string)   
 
Replace
 
Currently in C# it does not support Replace() function for string even stringbuilder Replace() also does character replacement and not string replacement. This function will find the characters passed in the second argument with the source string in first argument and replace it with 3rd argument.
 
Usage: Replace(Source,Find,Replacement) 
eg. Replace("abc","b","d") will return "adc" 
 
ToSingleSpace

ToSingleSpace is a function which will trims off multiple whitespace characters to single whitespace characters.
   
Usage:ToSingleSpace(SourceString) 
eg.ToSingleSpace("Welcome    to     C#") will return "Welcome to C#" 
  
CharCount 
 
This CharCount will no. of occurrences of a sub string in the main string. This will be useful in parsing functions.

Usage:CharCount(Source,Find) 
eg.CharCount("aaaaac","a")  will return 5
 
Reverse

This will reverse the String argument passed and return it.

Usage:Reverse(Source) 
eg.Reverse("abc") will return "cba" 
 
Left 
 
This will returns certain no.of characters from the beginning of the string. 

Usage:Left(Source,CharCount) 
eg. Left("Welcome",3) will return "Wel" 
  
Right
 
This will return certain no.of characters from the end of the String.

Usage:Right(Source,CharCount)  
eg. Right("Welcome",2) will return "me" 
 
IsPalindrome
 
This function will return whether the passed string is palindrome or not.
 
Usage:IsPalindrome(Source)  
eg.IsPalindrome("abc") will return false wherease IsPalindrome("121") will return true.

Up Next
    Ebook Download
    View all
    Learn
    View all