How to convert a string into int in C#?

CsharpProgrammingServer Side Programming

Let’s say our string is −

string str ="9999";

Now, use the Int32.Parse() to convert the string into integer −

int n = Int32.Parse(str);

Now display the integer value as shown in the following code −

Example

using System;
class Demo {
   static void Main() {
      string str ="9999";
      int n = Int32.Parse(str);
      Console.WriteLine(n);
   }
}
raja
Published on 21-Aug-2018 14:16:50
Advertisements