【问题标题】:Invalid expression term string无效的表达式术语字符串
【发布时间】:2013-10-19 17:03:00
【问题描述】:

我正在努力

 Console.WriteLine("Please enter a day of the week, e.g. Tue: ");
 today =  Console.ReadLine();
 GotoWork = string (today != SUN && today != SAT) ?

              Console.WriteLine("You have to go to work today...") ; 
              Console.WriteLine("Ahh... the weekend. No work!");'

编译并告诉我是否需要上班,但它告诉我'(today != SUN && today != SAT)' 是一个

invalid expression term for string.

【问题讨论】:

  • SUN 更改为"SUN",与SAT 相同,并阅读有关C# 语法的更多信息。

标签: c# if-statement compiler-errors


【解决方案1】:

用双引号括起来 SUNSAT,因为这是字符串的表示方式。

today != "SUN" && today != "SAT"

【讨论】:

    猜你喜欢
    • 2020-05-07
    • 1970-01-01
    • 2011-06-22
    • 2020-09-23
    • 2014-06-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-04
    • 2019-06-10
    相关资源
    最近更新 更多