• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    ASP.NET数组删除重复值实现代码

    根据这段代码,自己编写了一个小程序作为代码资料参考,方便以后可以直接拿来用,不需要网上找。如果你觉得还不错的话,就把它收藏起来吧!

    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 字符串、二进制、编码数组转换函数
    • asp.net 判断数组是否存在某个值的方法
    • asp.net(c#) 使用Rex正则来生成字符串数组的代码
    • asp.net通过js实现Cookie创建以及清除Cookie数组的代码
    • asp.net 数组中字符串替换的几种方式
    • vb.net 数组参与SQL语句的查询范例
    • ASP.NET MVC数组模型绑定详解
    • .NET数组使用中的注意事项小结
    • .NET下模拟数组越界的方法详解
    上一篇:GridView控件如何显示序号
    下一篇:ASP.NET中readonly与const的区别详解
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    ASP.NET数组删除重复值实现代码 ASP.NET,数组,删除,重复,值,