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.ConvertAll(a_temp,Int32.Parse)
'Array' does not contain a definition for ConvertAll
But when I referred to
https://msdn.microsoft.com/en-us/library/system.array(v=vs.110).aspx
he says that it exists (ConvertAll) in the System namespace.
, 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); } } }
, .NET Core, .NET Core. Full .NET Framework 4.6.x Enumerable Extensions :
.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();
Source: https://habr.com/ru/post/1675316/More articles:C ++ Although ending a loop with a function - c ++White screen after activating the screen Splash Screen - androidMultiple aggregations at one level in Elasticsearch-rails - ruby-on-railsHow to create a TEXT index in CouchDB 2.0? - couchdbIOS Swift Firebase instance ID returns Nil for the first time - iosiOS: Firebase token returning null - iosconstexpr reference to non-constant object - c ++How can I access the JPEG COM segment in iOS? - ioscalling Rest Api from Django admin panel - djangoIncluding a .dSYM file in a .ipa file - iosAll Articles