convert string to int csharp code example

Example 1: convert string array to int C#

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));
	}
}

Example 2: string to int c#

int x = Int32.Parse("1234");

Example 3: c# convert string to int

// Ask user for fave number
      Console.Write("Enter your favorite number!: ");
      
      // Turn that answer into an int
      int faveNumber = Convert.ToInt32(Console.ReadLine());

Example 4: letter to number converter c#

int index = (int)c % 32;