我是c#编程的初学者.我正在接受错误The name 'File' does not exist in the current context.
问题必须在线 var v = File.ReadLines("dictionary.txt");
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
if (args.Length > 0)
{
var v = File.ReadLines("dictionary.txt");
Run Code Online (Sandbox Code Playgroud)
vid*_*ige 16
只需将此using语句添加到您的文件顶部即可
using System.IO;
Run Code Online (Sandbox Code Playgroud)
编译器仅识别当前上下文中具有的名称空间中的类.使用using语句将名称空间添加到上下文中.您还可以使用完全限定的类型名称,例如System.IO.File引用该类.
如果您使用的是Visual Studio,还可以将光标放在有问题的符号(File)上并按Shift+ Alt+F10