Read double from console and do the calculation : double parse « Data Type « C# / CSharp Tutorial






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

    class Program
    {
        static void Main(string[] args)
        {
            double firstNumber, secondNumber;
            string userName;

            Console.WriteLine("Enter your name:");
            userName = Console.ReadLine();
            Console.WriteLine("Welcome {0}!", userName);
            Console.WriteLine("Now give me a number:");
            firstNumber = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Now give me another number:");
            secondNumber = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine(firstNumber + secondNumber);
            Console.WriteLine(firstNumber - secondNumber);
            Console.WriteLine(firstNumber * secondNumber);
            Console.WriteLine(firstNumber / secondNumber);
            Console.WriteLine(firstNumber % secondNumber);
        }
    }








2.29.double parse
2.29.1.Parsing strings to create data types: double
2.29.2.Parse Double with Exception handling
2.29.3.Read double from keyboard and parse it
2.29.4.Read double from console and do the calculation
2.29.5.Attempting to parse the string representation of either MinValue or MaxValue throws an OverflowException