如何用所有大写字母替换字符串 [英] How to Replace the String with all Capital letters

查看:148
本文介绍了如何用所有大写字母替换字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我从这样的数据库中获得一些名字

Dear Friends,

Iam getting some name from database like this

string FrstName=ds.Tables[0].Rows[0][5].ToString();


因此,在Frstname中,字符串就像这样的anil.现在,我想用所有大写字母(如ANIL)替换anil.我该怎么做,请建议我.


问候,

Anilkumar.


so,in Frstname the string is like this anil.Now i want to replace anil with all Capital letters Like ANIL.How can i do this please suggest me.


Regards,

Anilkumar.

推荐答案

尝试:
FrstName = FrstName.ToUpper();




所以现在我想用剩余的大写字母替换第一封信,这意味着anil应该转换Anil.应该如何替换?"



它称为标题大小写",而String类不包含它.但是TextInfo类可以.




"So Now i want to Replace Frist Letter with Capital Remainning small means anil should convert Anil.How should Replace?"



It''s called Title Case, and the String class does not include it. The TextInfo class does though.

CultureInfo cultureInfo = CultureInfo.CurrentCulture;
TextInfo textInfo = CultureInfo.CurrentCulture.TextInfo;
FrstName = textInfo.ToTitleCase(FrstName);


将.ToUpper()添加到您的代码行

Add .ToUpper() to your code line

string FrstName=ds.Tables[0].Rows[0][5].ToString().ToUpper();


添加:
using System.Globalization;


并尝试为:


and try as :

TextInfo UsaTextInfo = new CultureInfo("en-US", false).TextInfo;

       string capitalized = UsaTextInfo.ToTitleCase(FistName);


这篇关于如何用所有大写字母替换字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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