编译错误c#

编译错误c#,c#,C#,我有很多代码可以在VisualStudio中编译,但是在不同的ide中它不能编译 返回的错误是System.IO文件不包含“ReadLines”的定义 我正在使用system.io 与eror一起出现的代码部分是ReadLines 谁能给我一杯饮料吗 using System; using System.IO; // enable the user of different sections of the .net framework using Sy

我有很多代码可以在VisualStudio中编译,但是在不同的ide中它不能编译

返回的错误是System.IO文件不包含“ReadLines”的定义

我正在使用system.io

与eror一起出现的代码部分是ReadLines

谁能给我一杯饮料吗

using System;
using System.IO;                      // enable the user of different sections of the .net framework 
using System.Linq;
using System.Collections.Generic;
namespace HashTagAssignment
{
    class HashTag
    {
        static void Main(string[] args)
        {
            string tweets = File.ReadAllText(@"F:\tweets.txt"); // Retrives Text from file and loads into console
            {
                Console.WriteLine(tweets); // writes contense to console
                {
                    var lineCount = File.ReadAllLines(@"F:\tweets.txt").Length; // counts number of lines in the whole document
                    Console.WriteLine("Number of Lines:{0}", lineCount); // displays answer
                    {
                        var result = File.ReadLines(@"F:\tweets.txt").Distinct().Count(); // search txt file for Distinct enteries and implement counter. 
                        Console.WriteLine(" Number of Unique Tags: {0}", result); // display result of counter 
                        {
                            Console.WriteLine(" Top Twenty By Number:"); // Title Top twenty hash tags, with order they occured in left colum. 
                            Console.WriteLine(); // creates a line space 
                            var rank = File // assigns varible to a file 
                        .ReadLines(@"F:\tweets.txt") // directs to file, in this case text
                      .GroupBy(x => x)
    .Select(g => new { Key = g.Key, Count = g.Count() })
    .OrderByDescending(i => i.Count)
    .Take(20);
                            foreach (var item in rank)
                            {
                                Console.WriteLine("{0} {1}", item.Count, item.Key);
                            }
                            {
                                {
                                }
                                Console.ReadKey(true);
                            }
                        }
                    }
                }
            }
        }
    }
}

File.ReadLines
方法是.Net 4.0的新方法。

File.ReadLines在.Net 4.0之前不可用。您需要确保您是为.NET 4.0+或兼容版本的Mono进行编译。

如果您只是在其他IDE中遇到此错误,请确保您的解决方案/项目(如果其他IDE甚至使用它)具有对包含它的程序集的引用。我认为是mscorlib.dll


编辑:只是好奇,什么IDE?

让我们看看代码和错误?我们是想猜测另一个IDE吗?也许您试图在Netbeans中编译您的C#程序。请了解如何格式化代码为什么在几乎每个
控制台之后都要创建一个新的作用域块。WriteLine()
call?您是否意识到您正在读取同一个文件4次?它们是否是我可以用于3.5及以下版本的替代方案?我使用的编译器是sharpdevelop@Evildommer5您可以改为使用(.NET 2.0+),但这不会像
ReadLines
那样懒散地枚举。SharpDevelop的哪个版本?据该网站称,4.1将支持针对.NET4框架。哦。。。你放弃了你的mod能力?SharpDevelop不支持.NET4吗?为什么要从VS切换?因为我需要确保它在没有VS的计算机上编译。计算机只需要.NET 4运行时来运行程序,而不是Visual Studio。