fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApplication1
  6. {
  7. class Program
  8. {
  9. public static void Main(string[] args)
  10. {
  11. var test = new MyClass ();
  12.  
  13. }
  14.  
  15. class MyClass
  16. {
  17. private static readonly char[] InvalidChars = new[] { '\\', '/' };
  18.  
  19. public string Name { get; private set; }
  20.  
  21. public MyClass()
  22. {
  23. Name = "SomeName";
  24. //this line throws ArgumentNullException
  25. //for "source" parameter of Contains method
  26. var isValid = !Name.Any(x => InvalidChars.Contains(x));
  27. Console.WriteLine(isValid);
  28. }
  29.  
  30. }
  31. }
  32. }
  33.  
Success #stdin #stdout 0.03s 33880KB
stdin
Standard input is empty
stdout
True