Function to Convert Only First Letter Capital of each word in a sentence

public static string FirstLetterCapital(string strData)
      {
          string strReturn = string.Empty;
          strReturn = strData[0].ToString().ToUpper();
          
          for (int i = 1; i < strData.Length; i++)
          {
              strReturn += strData[i].ToString().ToLower();
              if (strData[i] == ' ' && (i+1) < strData.Length ) //
              {
                  strReturn +=  strData[i + 1].ToString().ToUpper();
                  i++;
              }
          }

          return strReturn;
      }
 Input: WINDOWS FORMS PROGRAMMING
 Output: Windows Forms Programming

posted @ 2012-04-01 14:37  sandeepparekh9  阅读(116)  评论(0编辑  收藏  举报