.NET Core: Array class does not contain a definition for ConvertAll

I am currently following https://www.hackerrank.com/challenges/diagonal-difference for my C # learning process. I copy and paste this code for C #. Here I need to convert a String array to Int Array. The sample code uses this for this Array.ConvertAll(a_temp,Int32.Parse). But in my Visual Studio Community 2017 IDE, it gives an error for the ConverAll method.

'Array' does not contain a definition for ConvertAll

But when I referred to

My IDE views

, IDE ConvertAll Method. , . IDE ( hackerrank)

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
{
    static void Main(String[] args)
    {
        int n = Convert.ToInt32(Console.ReadLine());
        int[][] a = new int[n][];
        for (int a_i = 0; a_i < n; a_i++)
        {
            string[] a_temp = Console.ReadLine().Split(' ');
            a[a_i] = Array.ConvertAll(a_temp, Int32.Parse);
        }
    }
}
+4
1

, .NET Core, .NET Core. Full .NET Framework 4.6.x Enumerable Extensions :

string[] a_temp = Console.ReadLine().Split(' ');
a[a_i] = a_temp.Select(s => Int32.Parse(s)).ToArray();
+5

Source: https://habr.com/ru/post/1675316/


All Articles