Why would it return rainyday[1] = Sunday and not friday ?? and elsewhere returning all the values defined in main()
Namespace ConsoleApp_toTestYourself
{
public struct forecast
{
public int temp { get; set; }
public int press { get; set; }
}
class structStaticTest
{
public static void cts(string weather) { weather = "sunny"; }
public static void cta(string[] rainyDays) { rainyDays[1] = "Sunday"; }
public static void ctsr(forecast f) { f.temp = 35; }
static void Main(string[] args)
{
string weather = "rainy";
cts(weather); //calling static method
Console.WriteLine("the weather is " + weather);
string[] rainyDays=new[]{"monday","friday"};
cta(rainyDays); calling static method
Console.WriteLine("the rain days were on "+rainyDays[0]+" and "+ rainyDays[1]);
forecast f = new forecast { press = 700, temp = 20 };
ctsr(f); //calling static method
Console.WriteLine("the temperature is " + f.temp + "degree celcius");
Console.ReadLine();
}
}
}
Its output is : Rainy Monday Sunday 20 degree celcius