Program.cs 898 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4. namespace D08._1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. if (args.Length < 1) throw new ArgumentException();
  11. if (File.Exists(args[0]) == false) throw new FileNotFoundException();
  12. int incode = 0, inmemory = 0;
  13. using (var file = File.OpenText(args[0]))
  14. {
  15. while (true)
  16. {
  17. var line = file.ReadLine();
  18. if (line == null) break;
  19. var nstring = Regex.Unescape(line.Substring(1, line.Length - 2));
  20. incode += line.Length;
  21. inmemory += nstring.Length;
  22. }
  23. }
  24. int answer = incode - inmemory;
  25. Console.WriteLine($"The answer is : {answer}");
  26. }
  27. }
  28. }