Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
1.89/5 (3 votes)
See more:
C#
ListBoxTidigareAnstallning.Items.Add(firstcharacterupper(empPreWork.prev_work_name_company_sve + "," + empPreWork.pre_work_city + " " + empPreWork.from_date
                         +"-"+empPreWork.to_date+empPreWork.pre_work_description_sve));


C#
public string firstcharacterupper(string str)
        {
            return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
        }



This code makes the first letter Uppercase. But for example Description if i will write some text every letter will get big but i only want the first character in description to be upcase
right now for example , description gets like this

Hi My Name Is Bill but i want to have Hi my name is bill
Posted

1 solution

Try this
C#
static string UppercaseFirst(string s)
   {
   // Check for empty string.
   if (string.IsNullOrEmpty(s))
   {
       return string.Empty;
   }
   // Return char and concat substring.
   return char.ToUpper(s[0]) + s.Substring(1).ToLower();
   }

Call the Method
C#
UppercaseFirst("Codeproject");

Hope this helps
 
Share this answer
 
v6
Comments
Kurac1 2-May-13 15:20pm    
it aint working?
CPallini 2-May-13 15:30pm    
Why are you defining a LowercaseFirst method and then invoking a UppercaseFirst one? :-D
By the way, my 5.
Kurac1 2-May-13 16:09pm    
hmm good question
CPallini 2-May-13 16:23pm    
However OP asked for UppercaseFirst. :-)
--Carlo The Nitpick
Jameel VM 3-May-13 4:40am    
OP asked for Uppercase but did u read the last sentence?'Hi My Name Is Bill but i want to have Hi my name is bill'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900