JS数组去掉重复 JQ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.cnblogs.com/sosoft/archive/2013/12/08/3463830.htmlhttp://www.cnblogs.com/novus/archive/2011/06/30/1921132.html一搜一大把。 不明白 楼主的 数据源 是"1,2,4,5,7,8,9"而结果 是 这个"1,2,3,4,5,7,8,9"为什么多一个3呢不知道 我给的答案对不对/// 去除重复 /// </summary> /// <param name="myData"></param> /// <returns>无重复</returns> private String[] RemoveDup(String[] myData) { if (myData.Length > 0) { Array.Sort(myData); int size = 1; //at least 1 for (int i = 1; i < myData.Length; i++) if (myData[i] != myData[i - 1]) size++; String[] myTempData = new String[size]; int j = 0; myTempData[j++] = myData[0]; for (int i = 1; i < myData.Length; i++) if (myData[i] != myData[i - 1]) myTempData[j++] = myData[i]; return myTempData; } return myData; } 写个去重的方法。先concat,再去重。 dataBF.concat(Str.split(',')).Distinct().sort().join(',');Array.prototype.Distinct=function(GetValue) { for(var Value=[],Hash={},Index=-1;++Index-this.length;) { var HashValue=GetValue?GetValue(this[Index]):this[Index]; if(!Hash[HashValue]) { Hash[HashValue]=1; Value.push(HashValue); } } return Value; }; [code=javascript]dataBF.concat(Str.split(',')).Distinct().sort().join(',');Array.prototype.Distinct=function(GetValue) { for(var Value=[],Hash={},Index=-1;++Index-this.length;) { var HashValue=GetValue?GetValue(this[Index]):this[Index]; if(!Hash[HashValue]) { Hash[HashValue]=1; Value.push(HashValue); } } return Value; };[/code] 关于.net remoting的疑问 数组元素大小排列问题 弹出窗口并传值给父窗口 使用delegate跨类UI控制 一个foreach的小问题 WCF如何能动态连接? //怎么用VC#写dll提供给VC++6.0或Delphi6.0调用? 怎样实现可停靠的工具窗口? C# 里用 API 太痛苦了。 C# 在DLL中使用发序列化的时候出现Unable to find assembly 异常,求助! QQ免费企业邮箱发送邮件不成功 C#读数据库“按日期提醒”索引3天内到期的数据
http://www.cnblogs.com/novus/archive/2011/06/30/1921132.html一搜一大把。
而结果 是 这个"1,2,3,4,5,7,8,9"
为什么多一个3呢
不知道 我给的答案对不对/// 去除重复
/// </summary>
/// <param name="myData"></param>
/// <returns>无重复</returns>
private String[] RemoveDup(String[] myData)
{
if (myData.Length > 0)
{
Array.Sort(myData);
int size = 1; //at least 1
for (int i = 1; i < myData.Length; i++)
if (myData[i] != myData[i - 1])
size++;
String[] myTempData = new String[size];
int j = 0;
myTempData[j++] = myData[0];
for (int i = 1; i < myData.Length; i++)
if (myData[i] != myData[i - 1])
myTempData[j++] = myData[i];
return myTempData;
}
return myData;
}
{
for(var Value=[],Hash={},Index=-1;++Index-this.length;)
{
var HashValue=GetValue?GetValue(this[Index]):this[Index];
if(!Hash[HashValue])
{
Hash[HashValue]=1;
Value.push(HashValue);
}
}
return Value;
};
Array.prototype.Distinct=function(GetValue)
{
for(var Value=[],Hash={},Index=-1;++Index-this.length;)
{
var HashValue=GetValue?GetValue(this[Index]):this[Index];
if(!Hash[HashValue])
{
Hash[HashValue]=1;
Value.push(HashValue);
}
}
return Value;
};[/code]