September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -3,17 +3,9 @@ using System.IO;
|
|||
|
||||
public class Rosetta
|
||||
{
|
||||
/* C# 6 version:
|
||||
public static void Main() => RemoveLines("foobar.txt", start: 1, count: 2);
|
||||
*/
|
||||
|
||||
public static void Main() {
|
||||
RemoveLines("foobar.txt", start: 1, count: 2);
|
||||
}
|
||||
|
||||
static void RemoveLines(string filename, int start, int count = 1) {
|
||||
//Reads and writes one line at a time, so no memory overhead.
|
||||
static void RemoveLines(string filename, int start, int count = 1) =>
|
||||
File.WriteAllLines(filename, File.ReadAllLines(filename)
|
||||
.Where((line, index) => index < start - 1 || index >= start + count - 1));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue