Skip to content

Instantly share code, notes, and snippets.

@gshzn
Created December 31, 2015 15:33
Show Gist options
  • Save gshzn/ce1a211d230f5fcd51d6 to your computer and use it in GitHub Desktop.
Save gshzn/ce1a211d230f5fcd51d6 to your computer and use it in GitHub Desktop.
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