fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. A[] a = new A[3];
  9. a[0] = new A(1);
  10. a[1] = new A(2);
  11. a[2] = new A(3);
  12.  
  13. Delete( ref a, new A(1));
  14. Console.WriteLine( a.Length );
  15. }
  16.  
  17. private static void Delete( ref A[] arr, A a )
  18. {
  19. var temp = new List<A>(arr);
  20. temp.Remove(a);
  21. arr = temp.ToArray();
  22. }
  23. }
  24.  
  25. public class A
  26. {
  27. int _i;
  28. public A( int i ){ _i = i; }
  29.  
  30. public override bool Equals( object o )
  31. {
  32. A a = o as A;
  33. return a != null && _i == a._i;
  34. }
  35.  
  36. public override int GetHashCode(){ return _i; }
  37.  
  38. public override string ToString(){ return _i.ToString(); }
  39. }
Success #stdin #stdout 0.03s 33968KB
stdin
Standard input is empty
stdout
2