|
|
|
|
|
by noblethrasher
5287 days ago
|
|
You can do the same thing in C# that you can in Ruby new FileEx (SOME_PATH, () => ConsoleEx.ReadLine (), () => ConsoleEx.CurrentLine != "QUIT").WriteAll ();
is equivalent to using (var file = new File(SOME_PATH))
{
string line = null;
try
{
while((line = Console.ReadLine) != "QUIT")
{
file.WriteLine(line);
}
}
catch (Exception ex)
{
throw;
}
finally
{
sw.Close();
}
}
|
|
It doesn't seem to be part of the framework though? Homegrown and _you_ expand it to something that is equivalent to the second code snippet?