Exemplo n.º 1
0
        static void Main()
        {
            generics::Dictionary <string, int> dict = new generics::Dictionary <string, int>()
            {
                ["A"] = 1,
                ["B"] = 2,
                ["C"] = 3
            };

            foreach (string name in dict.Keys)
            {
                System.Console.WriteLine($"{name} {dict[name]}");
            }
            // Output:
            // A 1
            // B 2
            // C 3
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Namespaces are heavily used in C# programming in two ways. First, .NET uses namespaces to organize its many classes, as follows:
            System.Console.WriteLine("Hello World!");

            // System is a namespace and Console is a class in that namespace.
            // The using keyword can be used so that the complete name is not required.
            Console.WriteLine("Hello World!");

            // The global namespace is the "root" namespace: global::System will always refer to the .NET System namespace.
            global::System.Console.WriteLine("Hello World");

            // Use the namespace alias qualifier :: to access the members of the aliased namespace.
            generics::Dictionary <string, int> dict = new generics::Dictionary <string, int>()
            {
                ["A"] = 1,
                ["B"] = 2,
                ["C"] = 3
            };
        }