Home » C#.Net

Int32.Parse() method with example in C#

C# Int32.Parse() method: Here, we are going to learn about the Parse() method of int (Int32) struct with its description, syntax, and example.
Submitted by IncludeHelp, on October 02, 2019

Int32.Parse() Method

This method is used to convert a string into an integer.

Syntax:

    int int.Parse(string str);

Parameter(s):

  • string str – represents a string object to be parsed.

Return value:

int – it returns an integer value.

Int32.Parse() Method Example in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = 0;
            
            Console.Write("Enter value of X: ");
            X = int.Parse(Console.ReadLine());

            Console.WriteLine("Value of X is : "+ X);
            
        }
    }
}

Output

Enter value of X: 12345
Value of X is : 12345






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.