C
C#15mo ago
Maybe Ange

❔ Just a question

Is it a false positive or not? Severity Code Description Project File Line Deletion Status Warning CS8600 Conversion of literal having null value or possible null value to non-nullable type. Rebootify D:\Documents\Rebootify\SoftwareRebootify\Software\Rebootify\ToolsPage.xaml.cs 30 Active
9 Replies
Denis
Denis15mo ago
what is the signature of the IPAddress,TryParse(...) method? is the out parameter an IPAddress or an IPAddress?
Maybe Ange
Maybe Ange15mo ago
I don't know I'm lost
Denis
Denis15mo ago
when you hover over the TryParse method, what is shown in the tooltip?
Maybe Ange
Maybe Ange15mo ago
Denis
Denis15mo ago
As you can see the method signature states, that it can output a nullable inststance of IPAddress. This is indicated with the ? after the type. So the warning you are receiving is not a false positive the solution to your problem would be one of the following Variant 1
if (!IPAddress.TryParse(boxIP, out IPAddress? ipAddress) || ipAddress is null)
{
MessageBox.Show("Adresse IP invalide.", "Erreur RBF-300-A");
return;
}
if (!IPAddress.TryParse(boxIP, out IPAddress? ipAddress) || ipAddress is null)
{
MessageBox.Show("Adresse IP invalide.", "Erreur RBF-300-A");
return;
}
Variant 2
if (!IPAddress.TryParse(boxIP, out var ipAddress) || ipAddress is null)
{
MessageBox.Show("Adresse IP invalide.", "Erreur RBF-300-A");
return;
}
if (!IPAddress.TryParse(boxIP, out var ipAddress) || ipAddress is null)
{
MessageBox.Show("Adresse IP invalide.", "Erreur RBF-300-A");
return;
}
Maybe Ange
Maybe Ange15mo ago
But in fact what I want to do is restart the internet box from a button click. In fact I have a Python code that runs when the button is clicked, I did it just for the wifi key and it works. Now for each user the ip address of the internet box will not be the same, so I have to do the same ip recovery system for the python script to be validated, except for the ip I can't do it
Maybe Ange
Maybe Ange15mo ago
Yes good
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts