您的位置:首页 > 编程语言 > C#

String Jargon in C# zz

2007-07-17 21:07 323 查看
http://www.c-sharpcorner.com/UploadFile/prasad_1/StringJargonPSD12062005020601AM/StringJargonPSD.aspx

Description


The following article shows solinkme 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.

zip
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: