Convert string read from console to double - CSharp Language Basics

CSharp examples for Language Basics:Console

Description

Convert string read from console to double

Demo Code

using System;/*from   w ww.  ja  v 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)
   {
      // Decimal input
      Console.Write("Enter a decimal number: ");
      string input = Console.ReadLine();
      double decimalNumber = Convert.ToDouble(input);
      // Repeating entered number to the output
      Console.WriteLine("You have entered number " + decimalNumber);
   }
}

Result


Related Tutorials