コード例 #1
0
        static void Main(string[] args)
        {
            FieldInfo[] fields = typeof(MyDictionary).GetFields();

            foreach (FieldInfo field in fields)
            {
                if (field.FieldType.IsArray)
                {
                    Array array = field.GetValue(null) as Array;

                    Console.WriteLine("Type: " + array.GetType().GetElementType().ToString());
                    Console.WriteLine("Length: " + array.Length.ToString());
                    Console.WriteLine("Values");
                    Console.WriteLine("------");

                    foreach (var element in array)
                    {
                        Console.WriteLine(element.ToString());
                    }
                }

                Console.WriteLine();
            }

            Console.Readline();
        }
コード例 #2
0
        static void Main(string[] args)
        {   /*
             * Console.WriteLine("Mata in tal 1: ");
             * string inmatat = Console.ReadLine();
             * int tal1 = int.Parse(inmatat);
             * Console.WriteLine("Mata in tal 2: ");
             * string inmatat2 = Console.ReadLine();
             * int tal2 = int.Parse(inmatat2);
             * Console.WriteLine("Summa: " + (tal1 + tal2));
             * Console.WriteLine("Produkt: " + (tal1 * tal2));
             * Console.WriteLine("Kvot: " + (tal1 / tal2));
             */
            Console.WriteLine("Mata in ditt förnamn: ");
            string inmatat = Console.Readline();
            string för     = string.Parse(inmatat);

            Console.WriteLine("Mata in ditt efternamn: ");
            string inmatat2 = Console.ReadLine();
            string efter    = string.Parse(inmatat2);

            Console.WriteLine("Hejsan, " + för + efter);
        }
コード例 #3
0
        static void Main(strings[] args)
        {
            bool[] doors = new bool[100];

            //Close all doors to start.
            for (int d = 0; d < 100; d++)
            {
                doors [d] = false;
            }

            //For each pass..
            for (int p = 0; p < 100; p++) // number of passes
            {
                //for each door to toggle...
                for (int d = 0; d < 100; d++)// door number
                {
                    if ((d + 1) % (p + 1) == 0)
                    {
                        doors[d] = !doors[d];
                    }
                }
            }

            //Output the results
            Console.WriteLine("Passes Completed!!! Here are the results: \r\n");
            for (int d = 0; d < 100; d++)
            {
                if (doors[d])
                {
                    Console.WriteLine(String.Format("Door#{0}: Open", d + 1));
                }
                else
                {
                    Console.WriteLine(String.Format("Door #{0}: Closed", d + 1));
                }
            }
            Console.Readline();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            DecimalNumber number = new DecimalNumber(Console.Readline());

            Console.WriteLine(numbers.NumberReversed());
        }