using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            WriteLine("Enter an integer:");
            int myInt = ToInt32(ReadLine());
            bool isLessThan10 = myInt < 10;
            bool isBetween0And5 = (0 <= myInt) && (myInt <= 5);
            WriteLine($"Integer less than 10? {isLessThan10}");
            WriteLine($"Integer between 0 and 5? {isBetween0And5}");
            WriteLine($"Exactly one of the above is true? {isLessThan10 ^ isBetween0And5}");
            ReadKey();
        }
    }
}

解决方案 »

  1.   

    需要在VS2015或者更新的VS上运行
      

  2.   

    1.这是C#6以上版本的语法,所以你需要至少vs2015以上版本,同时项目框架也得选择为6的框架
      

  3.   

    在上面输入
    using static System.Console;
    using static System.Convert;
      

  4.   

    你在visual studio 2017试试,一定可以,我之前也遇到了这个问题。
      

  5.   

    vs2017,.net framework 4.5+
      

  6.   


                Console.WriteLine("Enter an integer:");
                int myInt = Convert.ToInt32(Console.ReadLine());
                bool isLessThan10 = myInt < 10;
                bool isBetween0And5 = (0 <= myInt) && (myInt <= 5);
                Console.WriteLine($"Integer less than 10? {isLessThan10}");
                Console.WriteLine($"Integer between 0 and 5? {isBetween0And5}");
                Console.WriteLine($"Exactly one of the above is true? {isLessThan10 ^ isBetween0And5}");
                Console.ReadKey();
      

  7.   

    .net版本太低了