fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. var s = new Shape(1.0, 1.2);
  8. Console.WriteLine(s.NumberOfSides);
  9. }
  10. }
  11. public class Shape
  12. {
  13. // Keyword Initialized
  14. // ↓↓
  15. readonly double PI = 3.1416;
  16. public readonly int NumberOfSides;
  17. // ↑↑
  18.  
  19. // Keyword Not initialized
  20. public Shape(double side1, double side2) // Constructor
  21. {
  22.  
  23. // Shape is a rectangle
  24. NumberOfSides = 4;
  25. // ↑
  26. // ... Set in constructor
  27. }
  28. public Shape(double side1, double side2, double side3) // Constructor
  29. {
  30. // Shape is a triangle
  31. NumberOfSides = 3;
  32. // ↑
  33. // ... Set in constructor
  34. }
  35. }
Success #stdin #stdout 0.03s 33920KB
stdin
Standard input is empty
stdout
4