最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ASP.NET數(shù)組刪除重復(fù)值實(shí)現(xiàn)代碼

 更新時(shí)間:2015年10月10日 11:21:56   投稿:lijiao  
在ASP.NET編程中,要想刪除數(shù)組的重復(fù)值可以使用多種方法代碼實(shí)現(xiàn)相同的效果。今天,在某個(gè)博客中看到某功能代碼中的一小段代碼很不錯(cuò),它就是用來(lái)移動(dòng)數(shù)組中相同值的方法,分享給大家

根據(jù)這段代碼,自己編寫(xiě)了一個(gè)小程序作為代碼資料參考,方便以后可以直接拿來(lái)用,不需要網(wǎng)上找。如果你覺(jué)得還不錯(cuò)的話(huà),就把它收藏起來(lái)吧!

1.前臺(tái)代碼:

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
  <title>數(shù)組刪除重復(fù)值</title> 
</head> 
<body> 
  <form id="form1" runat="server"> 
  <div> 
    數(shù)組刪除前: 
    <asp:Label ID="lblResult1" runat="server"></asp:Label> 
    <br /> 
    數(shù)組刪除后: 
    <asp:Label ID="lblResult2" runat="server"></asp:Label> 
  </div> 
  </form> 
</body> 
</html>

2.后臺(tái)代碼:

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_數(shù)組_刪除重復(fù)值 : System.Web.UI.Page 
{ 
  protected void Page_Load(object sender, EventArgs e) 
  { 
    string strNum = "168,145,150,148,333,888,666,168,144"; 
    //輸出原數(shù)組 
    lblResult1.Text = strNum; 
    string[] arrNum = strNum.Split(','); 
    ArrayList al = new ArrayList(); 
    for (int i = 0; i < arrNum.Length; i++) 
    { 
      //判斷數(shù)組值是否已經(jīng)存在 
      if (al.Contains(arrNum[i]) == false) 
      { 
        al.Add(arrNum[i]); 
      } 
    } 
    //把ArrayList轉(zhuǎn)換數(shù)組 
    arrNum = new string[al.Count]; 
    arrNum = (string[])al.ToArray(typeof(string)); 
    //輸出刪除后數(shù)組 
    string result = ""; 
    for (int j = 0; j < arrNum.Length; j++) 
    { 
      if (j != 0) 
      { 
        result += ","; 
      } 
      result += arrNum[j]; 
    } 
    lblResult2.Text = result; 
  } 
}

3.最終輸出效果:

以上就是關(guān)于ASP.NET數(shù)組刪除重復(fù)值的實(shí)現(xiàn)方法,希望對(duì)大家的學(xué)習(xí)有所幫助。

相關(guān)文章

最新評(píng)論

临颍县| 九龙县| 郧西县| 嘉荫县| 云南省| 类乌齐县| 胶州市| 齐河县| 丰顺县| 兰西县| 马鞍山市| 绥阳县| 日喀则市| 射洪县| 韶山市| 桐乡市| 积石山| 福贡县| 襄城县| 正镶白旗| 探索| 乐都县| 佛冈县| 诸暨市| 丰镇市| 青神县| 商河县| 拉萨市| 双城市| 荔浦县| 游戏| 常德市| 英超| 怀化市| 四子王旗| 金川县| 衡阳县| 宜兰县| 色达县| 博野县| 当涂县|