将名字和姓氏的首字母改为大写

编程入门 行业动态 更新时间:2024-10-28 09:27:09
本文介绍了将名字和姓氏的首字母改为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想更改插入文本框的全名的前几个字母; 如果用户在转换后输入:"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.

更多推荐

将名字和姓氏的首字母改为大写

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

发布评论

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

>www.elefans.com

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