幽灵资源网 Design By www.bzswh.com
根据这段代码,自己编写了一个小程序作为代码资料参考,方便以后可以直接拿来用,不需要网上找。如果你觉得还不错的话,就把它收藏起来吧!
1.前台代码:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>数组删除重复值</title> </head> <body> <form id="form1" runat="server"> <div> 数组删除前: <asp:Label ID="lblResult1" runat="server"></asp:Label> <br /> 数组删除后: <asp:Label ID="lblResult2" runat="server"></asp:Label> </div> </form> </body> </html>
2.后台代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; //引用 public partial class NetObjects_数组_删除重复值 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string strNum = "168,145,150,148,333,888,666,168,144"; //输出原数组 lblResult1.Text = strNum; string[] arrNum = strNum.Split(','); ArrayList al = new ArrayList(); for (int i = 0; i < arrNum.Length; i++) { //判断数组值是否已经存在 if (al.Contains(arrNum[i]) == false) { al.Add(arrNum[i]); } } //把ArrayList转换数组 arrNum = new string[al.Count]; arrNum = (string[])al.ToArray(typeof(string)); //输出删除后数组 string result = ""; for (int j = 0; j < arrNum.Length; j++) { if (j != 0) { result += ","; } result += arrNum[j]; } lblResult2.Text = result; } }
3.最终输出效果:
以上就是关于ASP.NET数组删除重复值的实现方法,希望对大家的学习有所帮助。
标签:
ASP.NET,数组,重复值
幽灵资源网 Design By www.bzswh.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
幽灵资源网 Design By www.bzswh.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。