Hi All,
I have count number after find 3 digits in Button_1 and then put to the list D4.
My question is how to use back D4 in Button_2.
My code test;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Checking_13
{
public partial class Form1 : Form
{
public static List<string> D1 = new List<string>();
public static List<string> D2 = new List<string>();
public static List<string> D3 = new List<string>();
public static List<string> D4 = new List<string>();
public static List<string> D5 = new List<string>();
public static List<int> D6 = new List<int>();
List<int> interested = new List<int>();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string centerIds_list = ("101, 221, 324, 471, 114, 233, 341, 443, 101, 324, 728");
List<string> result = centerIds_list?.ToString().Split(',').Select(s => s.Trim()).ToList();
foreach (var Val in result)
{
listBox1.Items.Add(Val);
D1.Add(Val);
}
string centerIds_list_ = ("742, 101, 728, 221, 384, 471, 114, 233, 349, 443, 101, 247");
List<string> result_ = centerIds_list_?.ToString().Split(',').Select(s => s.Trim()).ToList();
foreach (var Val_ in result_)
{
listBox2.Items.Add(Val_);
D2.Add(Val_);
}
}
private void button1_Click(object sender, EventArgs e)
{
var c = D2.Where(x => D1.Contains(x));
foreach (var voc in c)
{
D3.Add(voc);
}
var r =D3.Cast<string>().Select(i => i.Split(',').Select(n => string.Concat(n.Trim().OrderBy(f => f))))
.SelectMany(a => a)
.GroupBy(n => n)
.Select(g => new { n = g.Key, f = g.Count() });
string[] LCount = r.Select(z => $"{z.n} = {z.f}").ToArray();
listBox3.Items.AddRange(LCount);
D4.Add(LCount.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
var SameNum = D4.Select(n => n.ToString()).Where(n => n.Distinct().Count() == 3).ToArray();
foreach (var Num_ in SameNum)
{
listBox4.Items.Add(Num_);
}
}
private void button3_Click(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
}
}
}