示例#1
0
        static void Main(string[] args)
        {
            GenericList <int> list1 = new GenericList <int>();

            list1.Add(1);

            GenericList <string> list2 = new GenericList <string>();

            list2.Add("");

            GenericList <ExampleClass> list3 = new GenericList <ExampleClass>();

            list3.Add(new ExampleClass());
        }
示例#2
0
        static void Main(string[] args)
        {
            Book myBook = new Book(123456789, "The Wind in the Willows", 3.99F);
            GenericList <Book> myBookList = new GenericList <Book>();

            myBookList.Add(myBook);
            //location of all generic collection types
            //System.Collections.Generic.

            GenericDictionary <string, Book> myGenDictExample = new GenericDictionary <string, Book>();

            myGenDictExample.Add("1234", myBook);

            var mynumber = new Nullable <int>(5);

            Console.WriteLine("My Number Has Valeu? : " + mynumber.HasValue);
            Console.WriteLine("MyNumber has value of ? : " + mynumber.GetValueOrDefault());
            Console.ReadLine();
        }