fork download
  1. public class MyClass
  2. {
  3. public int InstanceValue { get; set; }
  4. public int StaticValue { get; set; } // Это теперь экземплярный член
  5.  
  6. public MyClass(int instanceValue)
  7. {
  8. InstanceValue = instanceValue;
  9. StaticValue = instanceValue; // Здесь присваиваем значение экземплярному члену
  10. }
  11. }
  12.  
  13. class Program
  14. {
  15. static void Main(string[] args)
  16. {
  17. MyClass obj1 = new MyClass(1);
  18. MyClass obj2 = new MyClass(2);
  19.  
  20. Console.WriteLine(obj1.StaticValue); // Вывод: 1
  21. Console.WriteLine(obj2.StaticValue); // Вывод: 2
  22. }
  23. }
  24.  
Success #stdin #stdout 0.05s 26764KB
stdin
Standard input is empty
stdout
1
2