C
C#2y ago
kuulie

✅ What does the green squiggly mean on VS?

Why am I getting this green squiggly?
7 Replies
kuulie
kuulieOP2y ago
the sender is: <Button x:Name="sevenButton" Click="NumberButton_Click" Content="7" Margin="5" Grid.Row="2"/>
Kouhai
Kouhai2y ago
sender as Button could evaluate to null if sender is not a Button this is warning you that you might be dereferencing a null
kuulie
kuulieOP2y ago
ohh, what do i do
Angius
Angius2y ago
If you're sure sender is a Button use a direct cast ((Button) sender).Content
kuulie
kuulieOP2y ago
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
Angius
Angius2y ago
Idk, check if Content is string or string? You could always provide a fallback with ??
kuulie
kuulieOP2y ago
ok i think i got it from here, thanks guys
Want results from more Discord servers?
Add your server