-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
  • 43,651
  • 22
  • 107
  • 170
Katazui
  • 131
  • 1
  • 1
  • 5

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ç
  • 100,147
  • 13
  • 119
  • 184