【发布时间】:2020-08-23 18:59:12
【问题描述】:
我正在尝试编写一个计算器,但出现错误 CS0029。 这是代码:
using System;
namespace Calculator
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Calculator\n");
Rechnungplus();
}
static void Rechnungplus()
{
Console.WriteLine("after typing a/(every) number press enter.");
double a = Console.ReadLine();
double b = Console.ReadLine();
double c = a + b;
Console.WriteLine($"\n{a} + {b} = {c}");
}
}
}
我搜索了一个解决方案,但我发现了一个有类似问题的人提出的问题。有人说他/她应该尝试:
double a = (Console.ReadLine());
但这没有用。
【问题讨论】:
-
TryParse 方法是确保字符串中确实有数字的一种非常好的方法。
-
这能回答你的问题吗? read user input of double type
标签: c# compiler-errors