- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Convert.ToInt32 Method
Use Convert.ToInt32 method to convert text to an integer.
Firstly, set a string.
string str = "12";
Now, use the Convert.ToInt32() method the above string to number.
Convert.ToInt32(str);
Let us see the complete example.
Example
using System; class Program { static void Main() { string str = "12"; Console.WriteLine("String: "+str); int n = Convert.ToInt32(str); Console.WriteLine("Number: "+n); } }
Output
String: 12 Number: 12
Advertisements