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!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.