Convert string to integer in C#

In this article we will discuss about how to convert string to integer in C#.
  • 3411

Here we are converting string variable into integer variable. In this example two string variables are taken and they are converted into integer using Convert.ToInt32() method.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
    class Program
        static void Main(string[] args)
            string ss = "1234";
            string str = "123";
            int i = Convert.ToInt32(ss);
            int j = Convert.ToInt32(str);
            int k = i + j;


Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.