본문 바로가기
C#

Dictionary

by Mostlove 2023. 7. 9.
728x90
반응형

namespace CSharp1
{
    internal class Program
    {
        class Monster
        {
            public int id;
            public Monster(int id)
            {
                this.id = id;
            }
        }

        static void Main(string[] args)
        {
            List<int> list = new List<int>();   
            Dictionary<int, Monster> dic = new Dictionary<int, Monster>();
            for (int i = 0; i < 10000; i++)
            {
                dic.Add(i,new Monster(i));
            }
            Monster mon;
            bool found = dic.TryGetValue(2000, out mon);
            /*            dic.Add(0,new Monster(1));
                        dic[5] = new Monster(5);*/
            dic.Remove(7777);
            dic.Clear();
        }
    }
}

반응형

'C#' 카테고리의 다른 글

Interface  (0) 2023.07.10
Generic  (0) 2023.07.10
List  (0) 2023.07.09
다차원 배열  (0) 2023.07.09
배열 연습문제  (0) 2023.07.06