excel 두 줄 데이터 차이 빠르게 찾기

1311 단어 C#
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtA.Text) || string.IsNullOrEmpty(txtB.Text))
                return;

            rA.Text = GetDiff(GenDict(txtA.Text), GenDict(txtB.Text));
            rB.Text = GetDiff(GenDict(txtB.Text), GenDict(txtA.Text));
        }

        Dictionary GenDict(string value) {
            var dict = new Dictionary();
            var cols = value.Split('\t');
            for (int i = 0; i < cols.Length; i++)
            {
                if (!dict.ContainsKey(cols[i]))
                    dict.Add(cols[i], MyCommon.IntToLetter(i + 1));
                else
                    dict[cols[i]] = dict[cols[i]] + " | " + MyCommon.IntToLetter(i + 1);
            }
            return dict;
        }

        string GetDiff(Dictionary a, Dictionary b) {
            List ls = new List();
            foreach (var item in a)
                if (!b.ContainsKey(item.Key))
                    ls.Add(string.Format("{0}【{1}】",item.Key,item.Value));

            return string.Join(Environment.NewLine,ls);
        }

좋은 웹페이지 즐겨찾기