fork download
  1. public struct Forecast
  2. {
  3. public int Temperature { get; set; }
  4. public int Pressure { get; set; }
  5. }
  6.  
  7. class Program
  8. {
  9. public static void ChangeTheString(string weather) { weather = "sunny"; }
  10. public static void ChangeTheArray(string[] rainyDays) { rainyDays = new[]{"Sunday", "Tuesday"}; }
  11. public static void ChangeTheStructure(Forecast forecast) { forecast.Temperature = 35; }
  12. static void Main(string[] args)
  13. {
  14. string weather = "rainy";
  15. ChangeTheString(weather);
  16. System.Console.WriteLine("The weather is " + weather);
  17.  
  18. string[] rainyDays = new[] {"Monday", "Friday" };
  19. ChangeTheArray(rainyDays);
  20. System.Console.WriteLine("The rainy days were on " + rainyDays[0] + " and "+rainyDays[1]);
  21.  
  22. Forecast forecast = new Forecast {Pressure = 700, Temperature = 20 };
  23. ChangeTheStructure(forecast);
  24. System.Console.WriteLine("The temperature is " +forecast.Temperature + "C");
  25. System.Console.ReadKey();
  26. }
  27. }
Success #stdin #stdout 0.02s 22460KB
stdin
Standard input is empty
stdout
The weather is rainy
The rainy days were on Monday and Friday
The temperature is 20C