Int32.Parse() method with example in C#

C# Int32.Parse() technique: Here, we will find out about the Parse() strategy for int (Int32) struct with its portrayal, syntax, and example.

Int32.Parse() Method

This strategy is utilized to change over a string into an integer.

Syntax:

int int.Parse(string str);

Parameter(s):

  • string str – speaks to a string item to be parsed.

Return value:

int – it restores 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);
            
        }
    }
}

Leave a Comment

error: Alert: Content is protected!!