将名字和姓氏的首字母改为大写 [英] change the first letter of firstname and lastname into uppercase

查看:877
本文介绍了将名字和姓氏的首字母改为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改插入文本框的全名的前几个字母;

如果用户在转换后输入:"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?

推荐答案

您是否检查过?

http://msdn.microsoft.com/en-us/library/system. globalization.textinfo.totitlecase.aspx [ ^ ]

您可以使用如下所示的ToTitleCase()方法

Have you checked this?

http://msdn.microsoft.com/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.


这篇关于将名字和姓氏的首字母改为大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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