convert array from string to int csharp

Code Example - convert array from string to int csharp

                
                        string[] strings = new string[] {"1", "55", "3"}

int[] asIntegers = Array.ConvertAll(strings, int.Parse);
                    
                
 

convert string array to int csharp

                        
                                using System;

public class Example
{
	public static void Main()
	{
		string[] strings = new string[] {"1", "2", "3"};

		int[] ints = Array.ConvertAll(strings, s => int.Parse(s));
		Console.WriteLine(String.Join(",", ints));
	}
}
                            
                        
 

csharp convert string array to int array

                        
                                // Convert all the strings to integers
string[] stringIds = new string[] {"1", "2", "3"};
int[] ids = Array.ConvertAll(stringIds, s => {
  // The TryPrase() Method allows you to receive information
  // whether a element in the array was successfully converted
  bool success = int.TryParse(s, out int result);
  return result;
});