如何在第一次追逐时设置大写 [英] how to set uppercase only on first characted

查看:107
本文介绍了如何在第一次追逐时设置大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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







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

推荐答案

试试这个

Try this
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

UppercaseFirst("Codeproject");



希望这会有所帮助


Hope this helps


这篇关于如何在第一次追逐时设置大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆