Convert String into Pascal Case

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);


No responses found. Be the first to 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: