System.Console.Read C# (CSharp) Méthode

Read() public static méthode

public static Read ( ) : int
Résultat int
        public static int Read() { throw null; }
        public static ConsoleKeyInfo ReadKey() { throw null; }

Usage Example

            static void TryCatchStatement()
            {
                int num = 13, denom = 0, result;

                int[] myArray = { 22, 33, 55 };

                try
                {
                    result = num / denom;  // this is the first thing to break the app and will throw (DivideByZero)
                    result = myArray[num]; //since the first one is broken this won't be reached nor its exception
                }
                catch (DivideByZeroException error)
                {
                    //you can set a break point on this line to see the error description after being initialized
                    Console.WriteLine("We are in the first catch block");
                    Console.WriteLine(error.Message);
                }
                catch (IndexOutOfRangeException error)
                {
                    Console.WriteLine("We are in the second catch block");
                    Console.WriteLine(error.Message);
                }
                finally
                {
                    Console.WriteLine("Last thing to do once the app is broken"); //avoid memory leak - close connections and others
                }
                Console.Read();
            }
All Usage Examples Of System.Console::Read