有关数组操作的问题 string tmp=string.Empty;for(int i=0;i<substring.length;i++){if(substring[i]!=a){tmp+="_"+substring[i];}} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 int[] substring = new int[] { 1, 2, 3, 4, 5, 6 }; int _Index = Array.IndexOf(substring, 6); if (_Index == -1) { //没有6 } else { string _ValueText = ""; for (int i = 0; i != substring.Length; i++) { if (i == _Index) continue; _ValueText += "_" + substring[i].ToString(); } MessageBox.Show(_ValueText); }这样? int[] substring = new int[] { 1, 2, 3, 4, 5, 6 }; int _Index = Array.IndexOf(substring, 6); if (_Index == -1) { //没有6 } else { string _ValueText = ""; for (int i = 0; i != substring.Length; i++) { if (i == _Index) continue; // 如果等与6,不做加_的操作 _ValueText += "_" + substring[i].ToString(); } MessageBox.Show(_ValueText); } 不对啊,报错说+=这个符号无效啊invalid 把4楼的 continue 改成break就OK了一不小心写成死循环了,呵呵 偶尔在线,呵呵,不过帮人还挨骂,比较郁闷呢http://topic.csdn.net/u/20090708/08/a927b058-157c-470a-bf6d-4f916659ddf0.html using System.Collections; private string Fun(int iInput) { ArrayList alList = new ArrayList(); for (int i = 0; i < 7; i++) { alList.Add(i); } if (iInput > 0 && iInput < 7) { alList.Remove(iInput); string szOutput = ""; for (int i = 0; i < 6; i++) { szOutput += "_" + alList[i].ToString(); } return szOutput; } else { MessageBox.Show("错误的输入!"); return ""; } }写个函数给你试试看吧 int[] ii = new int[] { 1, 2, 3, 4, 5, 6 }; string str = ii.Where(i => i != 6).Aggregate("_", (s, i) => string.Format("{0}{1}{2}", s, i.ToString(), "_"), s=> s.TrimEnd('_')); vs打包问题,如何在安装之前进行注册,以防止任意拷贝 各位大神求救啊!UDP打洞出现的怪问题 有没有C#写的开源股票分析软件啊? 控制台程序的app.config配置文件是编译到exe里面了? 用fiddler看到的特殊的包 提问 ViewState Cache hidden 在什么情况下使用更合理。 如何在c#做脚本语言而编写的asp.net中,得到客户端计算机的ip地址 一个棘手的问题,C#获取word文档表格中的格式文本,获取不到编号,内。 用C#如何改写以下代码~谢谢 ASP.NET中的邮件发送接受问题 什么是电子商务的新方向 如何创建基于第三方控件的用户控件
if (_Index == -1)
{
//没有6
}
else
{
string _ValueText = "";
for (int i = 0; i != substring.Length; i++)
{
if (i == _Index) continue;
_ValueText += "_" + substring[i].ToString();
} MessageBox.Show(_ValueText);
}这样?
if (_Index == -1)
{
//没有6
}
else
{
string _ValueText = "";
for (int i = 0; i != substring.Length; i++)
{
if (i == _Index) continue; // 如果等与6,不做加_的操作
_ValueText += "_" + substring[i].ToString();
} MessageBox.Show(_ValueText);
}
invalid
一不小心写成死循环了,呵呵
偶尔在线,呵呵,不过帮人还挨骂,比较郁闷呢http://topic.csdn.net/u/20090708/08/a927b058-157c-470a-bf6d-4f916659ddf0.html
{
ArrayList alList = new ArrayList();
for (int i = 0; i < 7; i++)
{
alList.Add(i);
}
if (iInput > 0 && iInput < 7)
{
alList.Remove(iInput);
string szOutput = "";
for (int i = 0; i < 6; i++)
{
szOutput += "_" + alList[i].ToString();
}
return szOutput;
}
else
{
MessageBox.Show("错误的输入!");
return "";
}
}
写个函数给你试试看吧
int[] ii = new int[] { 1, 2, 3, 4, 5, 6 };
string str = ii.Where(i => i != 6).Aggregate("_",
(s, i) => string.Format("{0}{1}{2}", s, i.ToString(), "_"),
s=> s.TrimEnd('_'));