7 Replies
the sender is: <Button x:Name="sevenButton"
Click="NumberButton_Click"
Content="7"
Margin="5"
Grid.Row="2"/>
sender as Button
could evaluate to null if sender is not a Button
this is warning you that you might be dereferencing a nullohh, what do i do
If you're sure
sender
is a Button
use a direct cast
((Button) sender).Content
its still green and says Possible null reference argument for parameter 's' in 'int int.Parse(string s)'.
which means its saying Content might be null?
should i do this: Button clickedButton = (Button)sender;
string buttonText = clickedButton.Content.ToString();
thats from chatgpt
Idk, check if
Content
is string
or string?
You could always provide a fallback with ??
ok i think i got it from here, thanks guys