Advertisement
Guest User

Untitled

a guest
May 5th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1.  class Program
  2.     {
  3.         interface I
  4.         {
  5.             int X { get; set; }
  6.             void Calculate();
  7.         }
  8.  
  9.         struct S : I
  10.         {
  11.             public int X { get; set; }
  12.             public void Calculate() { X += 1; }
  13.         }
  14.  
  15.         static void Main(string[] args) {
  16.             I s = new S();
  17.             Console.WriteLine(s.X); // s.X == 0
  18.             Work(ref s);
  19.             Console.WriteLine(s.X); // s.X == 0, но надо сделать, чтобы было s.X == 1!!!
  20.             Console.ReadKey();
  21.         }
  22.  
  23.         static void Work(ref I   i) { i.Calculate(); }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement