I followed this thread to install Mono on my Fedora box:
Install Mono on Centos 5.5 using YUM
However, when I try and compile my program using:
gmcs foo.cs
I get:
foo.cs(11,44): error CS0117: `System.IO.File' does not contain a definition for `ReadLines'
/opt/novell/mono/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings
The line in question is:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
foreach(int currentMax in File.ReadLines(args[0]).Select(int.Parse))
{
...
}
Can anyone point me in the right direction?
So it looks like the problem is that you are using the
gmcs
compiler, which is designed specifically for targeting the .Net 2.0 runtime. The list of C# compilers for mono is:(see here for more details)
So the compiler you should be using for targeting .Net 4.0 is
dmcs
. Instead, if you actually intended to target .Net 2.0, then use theFile.ReadAllLines
method that @kil and @minitech talked about.