将所有首字母大写,休息每个字低 [英] Convert all first letter to upper case, rest lower for each word

查看:237
本文介绍了将所有首字母大写,休息每个字低的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本串(约5-6字居多),我需要转换。

目前的案文如下:

 这是个人文本眼下

我想将其转换为:

 这是我的文本,现在

我可以依次通过我收藏的字符串,但不知道如何去执行这个文本修改。


解决方案

 字符串s =这是我TEXT眼下;S = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(s.toLower());

I have a string of text (about 5-6 words mostly) that I need to convert.

Currently the text looks like:

THIS IS MY TEXT RIGHT NOW

I want to convert it to:

This Is My Text Right Now

I can loop through my collection of strings, but not sure how to go about performing this text modification.

解决方案

string s = "THIS IS MY TEXT RIGHT NOW";

s = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(s.toLower());

这篇关于将所有首字母大写,休息每个字低的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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