-1

I am trying to read a text file in reverse. I have the following:

StreamReader readtext = new StreamReader("log.txt");
string readmetext = readtext.ReadToEnd().Reverse();

Yet it gives me an error saying:

Error 1 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'string'. An explicit conversion exists (are you missing a cast?) c:\users\nat\documents\visual studio 2013\projects\windowsformsapplication1\windowsformsapplication1\orders.cs 23 33 WindowsFormsApplication1

How would I fix this?

Jeroen Vannevel
  • 42,521
  • 22
  • 100
  • 163
Katazui
  • 91
  • 1
  • 1
  • 4

1 Answers1

2

Reverse returns IEnumerable<char> try this, first convert it to char array then create new string:

string readmetext = new String(readtext.ReadToEnd().Reverse().ToArray());
Selman Genç
  • 97,365
  • 13
  • 115
  • 182