在控制台C#中写双

use*_*971 2 c# double console parsing

我需要你对C#的帮助.我正在创建这个程序:

static void Main()
    {
        Console.WriteLine("You weight is: ");
        double weight = Double.Parse(Console.ReadLine());
        Console.WriteLine("Your weight on Moon is: + {0}",weight*0.17);
     }
Run Code Online (Sandbox Code Playgroud)

问题是,当我启动程序和输入时,例如35.9,一个重量的数字,程序崩溃.

Gra*_*ICA 5

它没有崩溃.它关闭了.

Console.ReadLine()如果您希望窗口保持打开足够长的时间以阅读消息,则需要放置在方法的末尾.

static void Main()
{
    Console.WriteLine("You weight is: ");
    double weight = Double.Parse(Console.ReadLine());
    Console.WriteLine("Your weight on Moon is: + {0}",weight*0.17);

    Console.ReadLine();  // waits for input, allowing you to read the message
 }
Run Code Online (Sandbox Code Playgroud)