My current code is using Array.ConvertAll
, which I need to migrate to net core 1.0. How to migrate it to work in Net core.
Can we use foreach
statement with custom conversion code to handle the conversion?
But I don't know how to do it.
Any help is appreciated.
Instead of
int[] array1 = ...
string[] array2 = Array.ConvertAll(array1, element => element.ToString());
You could use Linq:
int[] array1 = ...
string[] array2 = array1.Select(element => element.ToString()).ToArray();
Only if you upgrade to latest .NET Core 1.0 official release (forget about all previous testing bits), you can use this method in System.Runtime
package,
https://learn.microsoft.com/en-us/dotnet/core/api/system.array#System_Array_ConvertAll__2___0___System_Converter___0___1__
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With