Only First Letter Capital

1:27 AM

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

1 comments:

{ CHAITANYA KIRAN KASANI } at: December 5, 2012 at 3:47 AM said...

Its Nice And Good...But It Has A Bug When We Want To Insert/Type A Letter Or Word In Between The Typed Word.Then The Cursor Control Is Always Jumps To End Of The Word..

Post a Comment