在一个字符串中出现多次的字符怎样让它只出现一次啊 ???比如 字符串:“大家好大家”
让“大家”只出现一次
让“大家”只出现一次
解决方案 »
- 这样的字符串截取如何做?
- 【求教】谁有HtmlTag类的完整版
- 如何在Button上加倒计时的功能
- 为什么txtbox获取不到数据···
- Repeater删除记录
- 简单正则(10000-fkdjfdjfjdjfkjkj)取其中的数字10000
- C#用EXCEL控件导出了EXCEL,但不能打开,原因是进程中多了一个EXCEL.EXE,如何在导出的时候把这个进程也关掉
- Repeater嵌套Repeater的问题寻求解决方法
- 求助 谁能让绑定在Datagrid的数据 在WEB窗口向下移动!?
- Visual C#.net 中能创建Activex exe吗?
- SerialPort串口通讯类
- 问下怎么关于反射赋值的问题?
string temp = "大家好大家";
string tempstr = "";
for (int i = 0; i <= temp.Length - 1; i++)
{
tempstr = temp.Substring(i, 1);
if (temp.IndexOf(tempstr) != i)
{
temp = temp.Remove(i, 1);
i = 0;
}
}
Console.WriteLine(temp);
{
if (arr.IndexOf(i) < 0)
{
arr.Add(i);
}
}
string result = Regex.Replace(yourStr, Regex.Escape(key), (MatchEvaluator)delegate(Match m)
{
if (!first)
{
return "";
}
else
{
first = false;
return m.Value;
}
});
{
string key = "大家";//指定只能出现一次的字符串
string yourStr = "大家好大家";
bool first = true;
//2005写法
string result = Regex.Replace(yourStr, Regex.Escape(key), (MatchEvaluator)delegate(Match m)
{
if (!first)
{
return "";
}
else
{
first = false;
return m.Value;
}
});
Console.WriteLine(result);
}