System.Collections.ArrayList hkArray=new System.Collections.ArrayList();//定义一个集合
string [] oldstr=new string [6];
oldstr[0]="you";
oldstr[1]="me";
oldstr[2]="they";
oldstr[3]="you";
oldstr[4]="he";
oldstr[5]="me";
string newstr=null;
int n=oldstr.Length;
for(int i=0;i<n;i++)
{
if(!hkArray.Contains(oldstr[i]))
{
hkArray.Add(oldstr[i]);
newstr=newstr+oldstr[i]+" ";
}
}
MessageBox.Show(newstr);
string [] oldstr=new string [6];
oldstr[0]="you";
oldstr[1]="me";
oldstr[2]="they";
oldstr[3]="you";
oldstr[4]="he";
oldstr[5]="me";
string newstr=null;
int n=oldstr.Length;
for(int i=0;i<n;i++)
{
if(!hkArray.Contains(oldstr[i]))
{
hkArray.Add(oldstr[i]);
newstr=newstr+oldstr[i]+" ";
}
}
MessageBox.Show(newstr);
解决方案 »
- C# winform combobox有两个名字分别为1和2当选择1的值时2的值也自动变成1选的值
- C#,传参顺序问题。
- SMS短消息PDU编码与解码
- 如何处理界面上控件与数据的链接关系。请各位大虾都来秀秀自己的经验。
- 如何利用C#锁键盘
- 请高手指点:引用出现的问题
- 在Winform里有没有实现执行本地的exe文件或者bat文件,获得输出的方法呢?
- Winform 页面传值小全~~
- 在.net中怎么样才能创建Office project?
- 如何得到一個窗體中所有 Component
- 返回数据集的问题
- WinForm中想实现当单击最小化按钮后,整个窗体以图标的形式缩小到右下角托盘中双击托盘的图标后恢复原窗体,怎么做?
从第二个开始检查,如果已经存在,不加入,如果不存在,加入