如何在第一次追逐时设置大写

编程入门 行业动态 更新时间:2024-10-24 20:17:48
本文介绍了如何在第一次追逐时设置大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

如何在第一次追逐时设置大写

本文发布于:2023-10-23 22:39:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!