top of page

Convert string to Integer in C#



In this article, we will write a C# program to convert string to Integer using Convert.ToInt32() method

 class Program
    {
        static void Main(string[] args)
        {
            string str1 = "5678";
            string str2 = "567";
            int i = Convert.ToInt32(str1);
            int j = Convert.ToInt32(str2);
            int k = i + j;
            Console.WriteLine(k);
            Console.ReadLine();

        }
    }

Output:

6245


Read more :

  1. Convert Float to String

  2. Convert Integer to String

  3. Convert String to Float



Source: csharpstar


The Tech platform

www.thetechplatform.com

0 comments
bottom of page