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 26028KB
stdin
public class Forecast

}

public int temperature; public int pressure;

public class Main

public static void changeTheString(String weather)

weather "sunny";

public static void changeTheArray(String[] rainyDays)

rainyDays [1] "Sunday";

public static void changeTheObject (Forecast forecast)

forecast temperature = 35;

public static void main(String[] args)

{

String weather = "rainy";

change TheString(weather);

System.out.println("The weather i * s ^ (- u) * eather ) ;

String[] rainyDays = new String[] ("Monday", "Friday");

changeTheArray(rainyDays); System.out.println("The rainy days were on rainyDays[0] + and rainyDays [1]

Forecast forecast = new Forecast(); forecast pressure = 700;

forecast temperature = 20 ; change TheObject(forecast),

System.out.println("The temperature is + forecast temperature "C");

}
stdout
The weather is rainy
The rainy days were on Monday and Friday
The temperature is 20C