本文介绍了将名字和姓氏的首字母改为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改插入文本框的全名的前几个字母; 如果用户在转换后输入:"Subash Neupane",则应为"Subash Neupane" 为此. 我使用了大写转换字符串函数
I want to change the first letters of full name inserted into the textbox; for if user inputs: "subash neupane" after conversion it should be "Subash Neupane" for this. I had used the uppercase conversion string function
public string change(string str1) { return char.ToUpper(str1[0]) + str1.Substring(1); }可以也提供一些提示来更改姓氏吗?
can give some hints how to change for the lastname too?
推荐答案您是否检查过? msdn.microsoft/en-us/library/system. globalization.textinfo.totitlecase.aspx [ ^ ] 您可以使用如下所示的ToTitleCase()方法 Have you checked this? msdn.microsoft/en-us/library/system.globalization.textinfo.totitlecase.aspx[^] You can use ToTitleCase() method like following string titleCaseString = new System.Globalization.CultureInfo("en").TextInfo.ToTitleCase("subash neupane");
以任何字符串存储全名. 然后使用空格作为字符串分隔符将其传输到字符串数组 然后为每个字符串做您首先要做的事情 最终将其串联起来. store full name in any string. then transfer it to string array using space as string seperator then do for each string what u have done for first finally cocatenate it.
更多推荐
将名字和姓氏的首字母改为大写
发布评论