Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            MyGeneric <Student> myGeneric = new MyGeneric <Student>();

            myGeneric.Field = new Student()
            {
                Fullname = "Khoa Nguyen"
            };
            Console.WriteLine(myGeneric.ToString());

            List <Student> students = new List <Student>()
            {
                new Student()
                {
                    Fullname = "Khoa Nguyen"
                }
            };

            var student = new Student()
            {
                Fullname = "Khoa Nguyen"
            };

            Dictionary <int, Student> std = new Dictionary <int, Student>();

            std.Add(1, new Student()
            {
                Fullname = "Khoa Nguyen"
            });

            foreach (int key in std.Keys)
            {
                std[key].Fullname = "sdf";
            }

            LinkedListNode <Student> linkedListNode = new LinkedListNode <Student>(student);
            LinkedList <Student>     std1           = new LinkedList <Student>();

            std1.AddLast(linkedListNode);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            MyGeneric <int> MyG = new MyGeneric <int>(5);

            MyG.SetItemValue(0, 10);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //Stack ts = new Stack();

            //Stack<int> vs = new Stack<int>();

            //Queue queue = new Queue();
            //Queue<string> vs1 = new Queue<string>();

            //vs1.Enqueue("Minh");

            //SortedList<int, Employee> list = new SortedList<int, Employee>();

            //Dictionary<string, Employee> emps = new Dictionary<string, Employee>();

            //LinkedList<Employee> employees = new LinkedList<Employee>();



            MyGeneric <Employee> myGeneric = new MyGeneric <Employee>();

            myGeneric.Add(new Employee()
            {
                EmployeeId = 1,
                Name       = "Khoa"
            });

            myGeneric.Add(new Employee()
            {
                EmployeeId = 2,
                Name       = "Minh"
            });
            myGeneric.Add(new Employee()
            {
                EmployeeId = 3,
                Name       = "Trung"
            });

            Console.WriteLine("--------------Print--------");
            foreach (var item in myGeneric.MG)
            {
                Console.WriteLine(item.ToString());
            }

            //var empRemove = myGeneric.MG[1];

            //myGeneric.Remove(empRemove);
            //Console.WriteLine("--------------Remove--------");
            //foreach (var item in myGeneric.MG)
            //{
            //    Console.WriteLine(item.ToString());
            //}

            //myGeneric.RemoveAt(0);
            //Console.WriteLine("--------------RemoveAt--------");
            //foreach (var item in myGeneric.MG)
            //{
            //    Console.WriteLine(item.ToString());
            //}

            //myGeneric.Update(0, new Employee()
            //{
            //    EmployeeId = 1,
            //    Name = "Tram"
            //});
            myGeneric.Update(myGeneric.MG[0], new Employee()
            {
                EmployeeId = 1,
                Name       = "Tram"
            });

            Console.WriteLine("--------------Print after update--------");
            foreach (var item in myGeneric.MG)
            {
                Console.WriteLine(item.ToString());
            }

            IndexerDemo <Employee> demo = new IndexerDemo <Employee>();

            demo[0] = new Employee()
            {
                EmployeeId = 1,
                Name       = "Khoa"
            };

            demo.Add(new Employee()
            {
                Name       = "Khoa",
                EmployeeId = 2
            });
        }