Day 16: Exceptions - String to Integer

  • + 0 comments
    C#
    
            string s = Console.ReadLine() ?? "";
            int ints = 0;
            try 
            {
                ints = int.Parse(s);
                Console.Write($"{ints}");
            }
            catch
            {
                Console.Write("Bad String");
            }