Convert console input to int and add ten - CSharp Language Basics

CSharp examples for Language Basics:int

Description

Convert console input to int and add ten

Demo Code

using System;/*from  ww w.  j av  a  2 s.  c  o  m*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Input
      Console.Write("Enter a number: ");
      string input = Console.ReadLine();
      int number = Convert.ToInt32(input);
      // Calculation
      number = number + 10;
      // Result output
      Console.WriteLine("Number ten more greater is: " + number);
   }
}

Result


Related Tutorials