Skip to content

Reading an array of N elements in C#

The first line contains N, the number of elements.

The next line contains N space-separated integers.

int N = Convert.ToInt32(Console.ReadLine());
int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
See also  Get URL without query string in C#

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.