0

我试过一些代码,比如

string s = "this is example";
txt1TextBlock.Text = Thread.CurrentCulture.TextInfo.ToTitleCase(s);

但似乎 WP7 Silverlight 它是不同的..

有什么办法吗?

谢谢..

4

2 回答 2

2

试试下面的,

String s = "this is example";
string result = "";
string[] words = s.Split(' ');
for (int i = 0, l = words.Length; i < l; ++i)
{
     result = result + words[i][0].ToString().ToUpper() + words[i].Substring(1) + " ";
}
MessageBox.Show("Old Value: "+s+" New Value: "+result);
于 2012-06-22T09:06:08.820 回答
0

因为我们在 Silverlight windows phone 的 String 类中没有 Split 方法。您应该使用基本的字符串函数,如 SubString()、Append()、Replace()、ToUpper() 和 ToLower()。

请参考以下教程..

http://www.c-sharpcorner.com/UploadFile/stephenarmbrust/FunctiontoChangeaBlockofTextofTitleCase11232005231948PM/FunctiontoChangeaBlockofTextofTitleCase.aspx

于 2012-06-20T08:43:50.820 回答