How to convert string to integer in C#

2 Answers

0 votes
using System;

class Program
{
    static void Main() {
        string str = "98473";

        int num = int.Parse(str);

        Console.WriteLine(num);
    }
}




/*
run:

98473

*/

 



answered Feb 10, 2023 by avibootz
0 votes
using System;

class Program
{
    static void Main() {
        string str = "74153";

        int num = Convert.ToInt32(str);

        Console.WriteLine(num);
    }
}




/*
run:

74153

*/

 



answered Feb 10, 2023 by avibootz

Related questions

1 answer 75 views
1 answer 82 views
1 answer 124 views
124 views asked Aug 11, 2021 by avibootz
1 answer 148 views
3 answers 336 views
1 answer 195 views
...