我尝试过像
这样的代码string s = "this is example";
txt1TextBlock.Text = Thread.CurrentCulture.TextInfo.ToTitleCase(s);
但似乎WP7 Silverlight与众不同..
有没有办法做到这一点?
感谢..
答案 0 :(得分: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);
答案 1 :(得分:0)
因为我们在Silverlight windows phone的String类中没有Split方法..你应该使用基本字符串函数,如SubString(),Append(),Replace(),ToUpper()和ToLower().. < / p>
请参阅以下教程..