• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2498
  • Last Modified:

Make first letter uppercase in a string in asp.net

how can i Make first letter uppercase in a string in asp.net
0
musclejack
Asked:
musclejack
1 Solution
 
mmarinovCommented:
Hi musclejack,

string name="mmarinov";
name.Substring(0,1).ToUpper();

Regards!
B..M
0
 
AerosSagaCommented:
Dim mystring As String = "howdy"
Dim myUpper As String = mystring.substring(0,1).toupper
Dim remainder as String mystring.substing(1)
DIm FinalString As String = myUpper & remainder

Aeros
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mmarinovCommented:
musclejack,

Aeros is correct , you have to add the rest of the string - my code makes just the first toupper and nothing else

Regards!
B..M
0
 
surajgupthaCommented:
This function makes "aaa bbb ccc" to "Aaa Bbb Ccc" also apart from what is expected
Hope it helps


# region Mask Word
/// <summary>
/// Masks the first character of each word in the string as Upper Case
/// </summary>
/// <param name="wordToMask">Input string</param>
/// <returns>Masked Word</returns>
private static string MaskWord(string wordToMask)
{
      string maskedWord="";;
      wordToMask=wordToMask.Trim();
      string[] namePieces=wordToMask.Split(' ');
      for (int counter=0;counter < namePieces.Length; counter++)
      {
            if ((namePieces[counter]!=null)&&(namePieces[counter].Trim().Length!=0))
            {
                  string currentWord=namePieces[counter].ToString();
                  int lengthOfCurrentWord=0;

                  // Make the first character of the word to Upper case
                  maskedWord+= currentWord[0].ToString().ToUpper();
                  
                  lengthOfCurrentWord=currentWord.Trim().Length-1;
                  if (lengthOfCurrentWord > 0)
                  {
                        // Add the remaining part of the word
                        maskedWord+= currentWord.Substring(1,lengthOfCurrentWord).ToLower();
                  }
            }
            maskedWord+=" ";
      }
      return maskedWord;
}
#endregion
0
 
Arthur_WoodCommented:
you can also use the strConv function, with the VbStrConv.ProperCase parameter:

Dim mystring As String = "howdy"
Dim FinalString As String = strConv(mystring, VbStrConv.ProperCase)


AW
0
 
kolluCommented:
Thank you for accepting my answer.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now