Read() public static méthode

public static Read ( ) : int
Résultat int
            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();
            }
Exemple #2
0
        static int Main(string[] args_)
        {
            try
            {
                SysConsole.WriteLine("Starting rainify console");

                return(Parser.Default.ParseArguments <Authorize, Status>(args_)
                       .MapResult(
                           (Authorize opts) => RunAuthorize(opts),
                           (Status opts) => RunStatus(opts),
                           errs => 1
                           ));
            }
            catch (Exception exc)
            {
                SysConsole.WriteLine("! " + exc.Message);
                SysConsole.WriteLine("! " + exc.StackTrace);
                return(1);
            }
            finally
            {
                SysConsole.WriteLine("Finished");
#if DEBUG
                SysConsole.Read();
#endif
            }
        }
Exemple #3
0
using S = System.Console; class A { static void Main()
                                    {
                                        for (int d = 1, c;; d = c > 83?1:++d % 51 - c % 2 * 51)
                                        {
                                            c = S.Read(); S.Write("#\n "[d < 1?0:c % 3]);
                                        }
                                    }
Exemple #4
0
 static void Main(string[] args)
 {
     Person person = new Person();
     person.name = "Tom";
     Printer.WriteLine(person.name);
     Printer.Read();
 }
        static void Main(string[] args)
        {
            var db   = SingleTonDatabase.Instance;
            var city = "Tokyo";

            WriteLine($"{city} has a population of {db.GetPopulation(city)}");
            Console.Read();
        }
Exemple #6
0
        public static char ReadChar(char stop_char = char.MinValue)
        {
            int char_value = BaseConsole.Read();

            if ((char_value >= char.MinValue) && (char_value <= char.MaxValue))
            {
                return(Convert.ToChar(char_value));
            }
            else
            {
                return(stop_char);
            }
        }
Exemple #7
0
 static void Main(string[] args)
 {
     using (var logger = Logger.Create())
     {
         using (var accidentStatisticDbContext = new AccidentStatisticDbContext(logger))
         {
             var accidentStatisticRepository = new AccidentStatisticRepository(accidentStatisticDbContext);
             var accidentCount = accidentStatisticRepository.Count().GetAwaiter().GetResult();
             logger.Information($"{accidentCount} Accident Statistic records found");
             logger.Information($"{accidentStatisticDbContext.Vehicles.LongCountAsync().GetAwaiter().GetResult()} Vehicle records found");
             logger.Information($"{accidentStatisticDbContext.Casualties.LongCountAsync().GetAwaiter().GetResult()} Casualty records found");
             LoadAllCyclingAccidents(accidentStatisticDbContext, new DateTime(2005, 01, 01, 1, 1, 1), new DateTime(2017, 12, 31, 1, 1, 1), logger).GetAwaiter().GetResult();
             logger.Warning("Hit enter to close");
             Console.Read();
         }
     }
 }
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Program is watching your directory, Ready to update your database as you insert your dlls");
            // Create a new FileSystemWatcher and set its properties.
            using (FileSystemWatcher watcher = new FileSystemWatcher())
            {
                watcher.Path = AppDomain.CurrentDomain.BaseDirectory;

                // Watch for changes in LastAccess and LastWrite times, and
                // the renaming of files or directories.
                watcher.NotifyFilter = NotifyFilters.LastAccess
                                       | NotifyFilters.LastWrite
                                       | NotifyFilters.FileName
                                       | NotifyFilters.DirectoryName;

                // Only watch text files.
                watcher.Filter = "*.dll";

                // Add event handlers.
                watcher.Changed += OnChanged;
                watcher.Created += OnChanged;
                watcher.Deleted += OnChanged;

                // Begin watching.
                watcher.EnableRaisingEvents = true;

                Console.ForegroundColor = ConsoleColor.Red;
                // Wait for the user to quit the program.
                Console.WriteLine("Press 'q' to quit the sample.");
                Console.ForegroundColor = ConsoleColor.Gray;

                //Refresh Database for the first run
                dbContext.RefreshDb();

                while (Console.Read() != 'q')
                {
                    ;
                }
            }
        }
Exemple #9
0
        static void Main(string[] args)
        {
            for (int i = 1; i < 10000; i++)
            {
                mKeys.Add(BitConverter.GetBytes(i));
            }

            mDatabase = new DB("mytestdb", new Options()
            {
                CreateIfMissing = true
            });
            IninDB();
            using (mDatabase)
            {
                //byte[] data = mDatabase.Get(mKeys[0]);
                // C.WriteLine(Encoding.UTF8.GetString(data));
                GetTestWithBuffer();
                GetTest();
            }
            C.WriteLine("test completed");
            C.Read();
        }
Exemple #10
0
        private static async Task MainAsync(string[] args)
        {
            Console.Write("Enter the puzzle number to solve: ");
            var puzzleNumber = int.Parse(Console.ReadLine());

            var puzzle = puzzles[puzzleNumber];

            Console.WriteLine("Starting " + puzzle.PuzzleName);

            Console.WriteLine("Solving puzzle A ... ");
            await Execute(puzzle.PuzzleA());

            Console.WriteLine();

            Console.WriteLine("Solving puzzle B ...");
            await Execute(puzzle.PuzzleB());

            Console.WriteLine();

            Console.WriteLine("Solution complete - press any key to continue.");
            Console.Read();
        }
        public void Method()
        {
            string         value;
            int            code;
            ConsoleKeyInfo key;

            code = System.Console.Read();   // Noncompliant {{Make sure that reading the standard input is safe here.}}
//                 ^^^^^^^^^^^^^^^^^^^^^
            code = Con.Read();              // Noncompliant

            value = Console.ReadLine();     // Noncompliant
            code  = Console.Read();         // Noncompliant
            key   = Console.ReadKey();      // Noncompliant
            key   = Console.ReadKey(true);  // Noncompliant

            Console.Read();                 // Compliant, value is ignored
            Console.ReadLine();             // Compliant, value is ignored
            Console.ReadKey();              // Compliant, value is ignored
            Console.ReadKey(true);          // Compliant, value is ignored

            Console.OpenStandardInput();    // Noncompliant
            Console.OpenStandardInput(100); // Noncompliant

            var x = System.Console.In;      // Noncompliant

//                  ^^^^^^^^^^^^^^^^^
            x = Console.In;    // Noncompliant
            x = Con.In;        // Noncompliant
            Console.In.Read(); // Noncompliant

            // Other Console methods
            Console.Write(1);
            Console.WriteLine(1);
            // Other classes
            MyConsole.Read();
            MyConsole.In.Read();
        }
 static void Main(string[] z)
 {
     try
     {
         for (dynamic c, p = z[0], a = new int[30000], s = new int[9], f = 1 > 0, i = 0, d = 0, t = 0;; i = c == 51 && f & (f |= s[--t] < 0)?s[t]:++i)
         {
             c = p[i] - 42;
             a[d += (c - 19) * (f & c > 17 & c < 21?1:0)] += (2 - c) * (f & c > 0 & c < 4?1:0);
             if (f & c == 4)
             {
                 C.Write((char)a[d]);
             }
             if (f & c == 2)
             {
                 a[d] = C.Read();
             }
             if (c == 49)
             {
                 s[t++] = f?(f = a[d] != 0)?i:-1:i;
             }
         }
     }
     catch {}
 }