开发者

Use of ToTitleCase

开发者 https://www.devze.com 2022-12-11 07:20 出处:网络
I wonder if anyone can help, I am trying to change something from caps to lower case with the Caps first letter, I undertsand I can use ToTitleCase - but I\'m struggling to get this going;

I wonder if anyone can help, I am trying to change something from caps to lower case with the Caps first letter, I undertsand I can use ToTitleCase - but I'm struggling to get this going;

 &开发者_高级运维lt;%= Html.Label("rblDeposit." + (i + 1).ToString(), item.Text.ToLowerInvariant())%>

I understand I need to supply a string into the ToTitleCase, but how do I do apply this to item.text part ?

I thought I could do something like this;

<%= Html.Label("rblDeposit." + (i + 1).ToString(), item.Text.ToTitleCase(item.Text))%>

Thanks


If you do not want to use the current CultureInfo, you can use the static InvariantCulture:

System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase(item.Text)

Hope that helps.


ToTitleCase is defined in the TextInfo class, that you can reach through the current CultureInfo:

CultureInfo.CurrentCulture.TextInfo.ToTitleCase(item.Text)


ToTitleCase is a method of TextInfo, not Text. Get a TextInfo from a CultureInfo.TextInfo; in particular, try CultureInfo.CurrentCulture.TextInfo.

0

精彩评论

暂无评论...
验证码 换一张
取 消