我试过一些代码,比如
string s = "this is example";
txt1TextBlock.Text = Thread.CurrentCulture.TextInfo.ToTitleCase(s);
但似乎 WP7 Silverlight 它是不同的..
有什么办法吗?
谢谢..
我试过一些代码,比如
string s = "this is example";
txt1TextBlock.Text = Thread.CurrentCulture.TextInfo.ToTitleCase(s);
但似乎 WP7 Silverlight 它是不同的..
有什么办法吗?
谢谢..
试试下面的,
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);
因为我们在 Silverlight windows phone 的 String 类中没有 Split 方法。您应该使用基本的字符串函数,如 SubString()、Append()、Replace()、ToUpper() 和 ToLower()。
请参考以下教程..