int i = str.indexof("_");
string str2 = str.substring(i+1,1).ToUpper();
str.replace("_"+str2.ToLower(),str2);
string str2 = str.substring(i+1,1).ToUpper();
str.replace("_"+str2.ToLower(),str2);
解决方案 »
- 求高手 c# winform
- TCP发送SMTP邮件中,连接成功但输入EHLO了后就接不到服务器的回复指令了,求解啊!!!
- sql时间段问题
- 各位大大们帮帮忙呀,简单问题,小弟在线等
- gridview中的列能像下拉框那样,显示的是某值,存的是另外一个值吗
- 美国中国时间,对在美国工作的中国人有很大的帮助
- ####急急急####SharePoint里面怎么查询一个时间段
- C#调用windows api 给第三方软件界面传值
- 在线等!!!急急!!如何把DropDownLIst中的数据清除!!
- 谁帮我解决这个问题,有高分相送
- 如何用listview动态显示新加入的数据
- 如何通过.net C#生成word文档
private void button1_Click(object sender, EventArgs e)
{
/*
字符串的转换函数
例如: Hello_i 变成 HelloI
要求遇到下划线去掉 且下划线后面如果是小写变成大写需要
*/
string yourStr = "Hello_i";
string destStr = Regex.Replace(yourStr, "_[a-zA-Z]", MyMatchEvaluator);
MessageBox.Show(destStr);
}public string MyMatchEvaluator(Match match)
{
return match.Value.Substring(1).ToUpper();
}
我说的是一楼的
二楼的shile,可以实现
二楼的引用空间是 System.Text.RegularExpressions
string yourStr = "heelo_ied_tr";
string destStr = Regex.Replace(yourStr, @"(\b|_)\w",
new MatchEvaluator(delegate(Match match) {
return match.Value.Trim('_').ToUpper(); }));
MessageBox.Show(destStr);
int index = s.IndexOf("_");
if (index > -1)
s = Replace(s, index);
string Replace(string s, int index)
{
s = s.Replace(s.Substring(index + 1, 1), s.Substring(index + 1, 1).ToUpper());
s = s.Remove(index,1);
if ((index=s.IndexOf("_")) > -1)
{
s = Replace(s, index);
} return s;
}
string aa = "heelo_ied_tr";
string[] ArrayString = aa.Split('_');
string Result = "";
for (int i = 0; i < ArrayString.Length; i++)
{
string temp = ArrayString[i].Substring(0,1).ToUpper();
Result +=temp+ArrayString[i].Substring(1);
}
textBox1.Text = Result;试试我这个吧,嘿嘿