如何利用名称 [英] How to Capitalize names

查看:141
本文介绍了如何利用名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上,如果我想从

so basically if i want to transform a name from

stephen smith 

Stephen Smith

我可以很容易地做到这一点与CSS来在页面上,但最好我想在前面抓住它,改变它时,它散发出来的数据库。我怎样才能CSHARP到captialize字符串。

i can easily do it with come css on the page but ideally I would like to catch it earlier on and change it when it comes out of the database. how can i get csharp to captialize a string.

有一个功能呢?

推荐答案

您可以使用的 ToTitleCase 办法做到这一点://支持.microsoft.com / KB / 312890> System.Globalization.TextInfo 类:

You can do this using the ToTitleCase method of the System.Globalization.TextInfo class:

CultureInfo cultureInfo   = Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = cultureInfo.TextInfo;

Console.WriteLine(textInfo.ToTitleCase(title));
Console.WriteLine(textInfo.ToLower(title));
Console.WriteLine(textInfo.ToUpper(title));

这篇关于如何利用名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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