예제 #1
0
파일: Form1.cs 프로젝트: kPlusPlus/CrcMrc
        public void TestIntersect()
        {
            Int32[] iHwnd    = new Int32[] { 199576, 199576, 199576, 199576, 199576, 199576, 199576, 199576, 199576, 199576 };
            Int32[] lprozori = new Int32[] { 330488, 134094, 199576, 723984, 199726, 590452, 199580, 134052 };

            Int32[] commonElements = iHwnd.Intersect(lprozori).ToArray();
            Int32[] commonExept    = iHwnd.Except(lprozori).ToArray();
        }
예제 #2
0
        private void btnDistinct_Click(object sender, EventArgs e)
        {
            var cohort1 = new Int32[] { 3, 5, 1, 8, 2, 51 };
            var cohort2 = new Int32[] { 23, 45, 51, 86, 21 };

            // không lấy phần tử trùng nhau
            //var query = cohort1.Distinct();

            // cohort1 + cohort2
            //var query = cohort1.Union(cohort2);

            // lấy giao của cohort1 với cohort2
            //var query = cohort1.Intersect(cohort2);

            // lấy ngoại trừ
            var query = cohort1.Except(new int[] { 8, 51 });

            foreach (var item in query)
            {
                listBox1.Items.Add(item);
            }
        }