Could anyone please explain to me why ,in those two casting scenarios below, the casted variables acts different? While first variable (double initial) preserves its initial value in the first example code, the "sender" object changes its content property value according to the new variable which it was casted into?
1st ex:
double initialValue = 5;
int secValue = (int)initial;
secValue = 10;
Console.WriteLine(initial); // initial value is still 5.
2nd ex:
private void Button_Click(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
btn.Content = "Clicked"; // "sender" objects content property is also set to "Clicked".
}