Wednesday, October 28, 2020

Finding the Duplicate Numbers in ASP.NET

 I show you how to write a program that will determine which of the numbers in the given list is duplicate using Microsoft ASP.NET.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.





Program Listing


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Duplicate
{
    public partial class _Default : System.Web.UI.Page
    {
               

    
        protected void Button1_Click1(object sender, EventArgs e)
        {
           Dictionary<int, string> num_bers = new Dictionary<int, string>() {  
            {1,"1"},  
            {2,"2"},  
            {3,"3"},  
            {4,"4"},  
            {5,"3"},  
            {6,"1"},  
            {7,"1"},
            {8,"1"},  
            {9,"4"},
            {10,"4"}  
        };

        Label1.Text = "List of Numbers..........";
        foreach (KeyValuePair<int, string> pair in num_bers)
        {
            Label1.Text += "<br />" + pair.Key + " ........ " + pair.Value;
        }

        //get dictionary duplicate values.
        var duplicatesValue = num_bers.GroupBy(x => x.Value).Where(x => x.Count() > 1);

        Label1.Text += "<br /><br />List of Numbers that has Duplicate Values..........<br />";  
        foreach(var item in duplicatesValue)
        {
            Label1.Text += item.Key + "<br />";
        }
        }

        
        }

       
    }




No comments:

Post a Comment