Day 16: Exceptions - String to Integer

  • + 1 comment

    Where is the d*mn error here:

    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.Collections;
    using System.ComponentModel;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Reflection;
    using System.Runtime.Serialization;
    using System.Text.RegularExpressions;
    using System.Text;
    using System;
    
    
    
    class Solution
    {
        
        public static void Main(string[] args)
        {
            try {
                List<string> numsInInput = new List<string>();
            
                string S = Console.ReadLine();
                
                int num = Int32.Parse(S); // try to convert the string to int
                
                for(int i = 0; i < S.Length ; i++) {
                    numsInInput.Add(S.Substring(i, 1));
                }
                
                if (numsInInput.Count() > 0) {
                foreach (string s in numsInInput) {
                    Console.Write(s);
                }    
                }
            } catch (Exception ex) {
                Console.WriteLine("Bad String");
            } finally {
                //
            }
            
            //FindTheNumbersInInput(S, ref numsInInput);
            /*if (numsInInput.Count() > 0) {
                foreach (string s in numsInInput) {
                    Console.Write(s);
                }
            }*/
        }
    }