Resources » Code Snippets » String Manipulations

Convert String into Pascal Case


Posted Date: 30-Dec-2009  Last Updated:   Category: String Manipulations    
Author: Member Level: Gold    Points: 4



This method is used for conversion of input string into pascal case



private string ConvertToPascal(string strFileName)
{
if (strFileName == null) throw new ArgumentNullException("strException", "Null is not a valid string!");
if (strFileName.Length == 0) return strFileName;
string[] strWords = strFileName.Split(' ');
for (int i = 0; i < strWords.Length; i++)
{
if (strWords[i].Length > 0)
{
string strWord = strWords[i];
char strFirstLetter = char.ToUpper(strWord[0]);
strWords[i] = strFirstLetter + strWord.Substring(1);
}
}
return string.Join(" ", strWords);
}



Did you like this resource? Share it with your friends and show your love!

Responses to "Convert String into Pascal Case"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India