Created
December 31, 2015 15:33
-
-
Save gshzn/ce1a211d230f5fcd51d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Give me a few numbers: (Split them by a , (comma))"); | |
int[] numbers = parse(Console.ReadLine().Split(',')); | |
Console.ReadLine(); | |
} | |
public static int[] parse(string[] args) | |
{ | |
int[] array = new int[] { }; | |
for (int i = 0; i < args.Length; i++) | |
{ | |
try | |
{ | |
Console.WriteLine(i + " = " + args[i]); | |
array[i] = int.Parse(args[i].Trim()); | |
} catch (IndexOutOfRangeException ex) | |
{ | |
Console.WriteLine(ex.GetBaseException()); | |
} | |
} | |
return array; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment