블로그 이미지
010-9967-0955 보미아빠

카테고리

보미아빠, 석이 (500)
밥벌이 (16)
싸이클 (1)
일상 (1)
Total
Today
Yesterday

달력

« » 2024.3
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

공지사항

최근에 올라온 글

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace mtest2

{

    class Config

    {

        public class Item : IEquatable<Item>

        {

            private readonly string _X;

            private readonly string _Y;


            public Item(string x, string y)

            {

                _X = x;

                _Y = y;

            }


            public string X

            {

                get { return _X; }

            }


            public string Y

            {

                get { return _Y; }

            }


            public override int GetHashCode()

            {

                return _X.GetHashCode() ^ _Y.GetHashCode();

            }



            public bool Equals(Item other)

            {

                if (_X != other._X)

                    return false;


                return _Y == other._Y;

            }            


        }

    }

}




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace mtest2
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<Config.Item, string> dicReloadedItems = new Dictionary<Config.Item, string>();
            Dictionary<Config.Item, string> dicCurrentItems = new Dictionary<Config.Item, string>();
            dicReloadedItems.Add(new Config.Item("1key", "1value"), "dic.1value");
            dicReloadedItems.Add(new Config.Item("2key", "2value"), "dic.2value");
            dicReloadedItems.Add(new Config.Item("3key", "3value"), "dic.3value");

            dicCurrentItems.Add(new Config.Item("3key", "3value"), "dic.3value");
            dicCurrentItems.Add(new Config.Item("4key", "4value"), "dic.4value");

            foreach (var dicReloadedItem in dicReloadedItems)
            {
                if (!dicCurrentItems.ContainsKey(dicReloadedItem.Key))
                {
                    Console.WriteLine(string.Format("a{0}, {1}", dicReloadedItem.Key.X, dicReloadedItem.Key.Y));
                }
            }
            Console.ReadKey();
        }
    }
}






//-----------------------------------------------------------------------------------------

// tuple 이용하기 .net 4.0 이상 조오타~~~

//-----------------------------------------------------------------------------------------


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace mtest2

{

    class Program

    {

        static void Main(string[] args)

        {

            Dictionary<Tuple<string, string>, string> dicReloadedItems = new Dictionary<Tuple<string, string>, string>();

            Dictionary<Tuple<string, string>, string> dicCurrentItems = new Dictionary<Tuple<string, string>, string>();

            dicReloadedItems.Add(new Tuple<string, string>("1key", "1value"), "dic.1value");

            dicReloadedItems.Add(new Tuple<string, string>("2key", "2value"), "dic.2value");

            dicReloadedItems.Add(new Tuple<string, string>("3key", "3value"), "dic.3value");


            dicCurrentItems.Add(new Tuple<string, string>("3key", "3value"), "dic.3value");

            dicCurrentItems.Add(new Tuple<string, string>("4key", "4value"), "dic.4value");


            foreach (var dicReloadedItem in dicReloadedItems)

            {

                if (!dicCurrentItems.ContainsKey(dicReloadedItem.Key))

                {

                    Console.WriteLine(string.Format("a{0}, {1}", dicReloadedItem.Key.Item1, dicReloadedItem.Key.Item2));

                }

            }

            Console.ReadKey();

        }

    }

}



Posted by 보미아빠
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함