-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simple terms please- what do i do about it #34522
Comments
Hi @edthehorse Can you add some details on which terms aren't defined or aren't clear? That will help us resolve this. |
Thanks Bill
I think I understand that eg string is not nullable and this is causing warnings
Some say use string? to make it nullable. Others say use the ! of the ?? etc etc.
From your and other websites! I cannot see any definitive way of dealing with it. Confusing to say the least.
I pity a new-comer reading that – and they’re the ones who’d encounter these warnings !
How about making this Help directed at a newbie! :-)
Sorry for the negativity
Regards
Ed
From: Bill Wagner ***@***.***>
Sent: Monday, March 13, 2023 1:15 PM
To: dotnet/docs ***@***.***>
Cc: ed ***@***.***>; Mention ***@***.***>
Subject: Re: [dotnet/docs] simple terms please- what do i do about it (Issue #34522)
Hi @edthehorse <https://github.com/edthehorse>
Can you add some details on which terms aren't defined or aren't clear? That will help us resolve this.
—
Reply to this email directly, view it on GitHub <#34522 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB6M5UD7NOR5E7ROVCIF2MTW34MWVANCNFSM6AAAAAAVY7S2PU> .
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
OK
I don’t expect you to be my personal Help Assistant 😊 but maybe put yourself in my shoes
which is how I arrived at your site.
How would I resolve this warning from code like this
Table1 t1 = new Table1();
t1 = (Table1) serializer.Deserialize(reader);
where would I specifivcally find help on your site to help me with this (apart from turning off the warning :-)
ie
If I look up help on the CS8600 – no idea.
BTW Im a teacher of this stuff believe it or not :-) so Im just trying to tell my students what to DO.
From: Bill Wagner ***@***.***>
Sent: Monday, March 13, 2023 1:15 PM
To: dotnet/docs ***@***.***>
Cc: ed ***@***.***>; Mention ***@***.***>
Subject: Re: [dotnet/docs] simple terms please- what do i do about it (Issue #34522)
Hi @edthehorse <https://github.com/edthehorse>
Can you add some details on which terms aren't defined or aren't clear? That will help us resolve this.
—
Reply to this email directly, view it on GitHub <#34522 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB6M5UD7NOR5E7ROVCIF2MTW34MWVANCNFSM6AAAAAAVY7S2PU> .
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Thanks @edthehorse That helps a lot. First, the specific question: Table1 t1 = new Table1();
t1 = (Table1) serializer.Deserialize(reader); The There are two fixes:
t1 = (Table1)serializer.Deserialize(reader) ?? new Table1();
t1 = (Table1) serializer.Deserialize(reader)!; Second, to fix this for other readers that encounter the same situation: I think the overview of Nullable reference types provides the background needed to understand why these warnings get generated. Do you agree? If so, I'll add a link to that article, and recommend it for anyone unfamiliar with the feature. We want to keep the error pages as brief as possible. People want to understand the error quickly, and get on with their programming! For that reason, I don't want to replicate the entire overview here. If a paragraph introduction would help, I'll add it. Thanks for the responses to help us make this better for everyone! |
Hello Bill
Once again thanks for your assistance
I still mean to answer your question one day when capable :-)
While you’re here – another matter.
Have you noticed that Microsoft’s WeatherForcast service in their web api stuff is erroneous?.
Eg -2 deg Celsius is sweltering etc.
Eg in the standard microsoft Blazor app.
It must have gone out in millions of apps?
I’ve made what I think is a fix but I wonder if anyone was concerned ?
Regards
Ed
From: Bill Wagner ***@***.***>
Sent: Tuesday, March 14, 2023 2:14 PM
To: dotnet/docs ***@***.***>
Cc: ed ***@***.***>; Mention ***@***.***>
Subject: Re: [dotnet/docs] simple terms please- what do i do about it (Issue #34522)
Thanks @edthehorse <https://github.com/edthehorse>
That helps a lot.
First, the specific question:
Table1 t1 = new Table1();
t1 = (Table1) serializer.Deserialize(reader);
The Deserialize method could return null. The compiler issues CS8600 if you assign a value that might be null to a variable whose type is not null. Table is a non-nullable reference.
There are two fixes:
1. Provide a default:
t1 = (Table1)serializer.Deserialize(reader) ?? new Table1();
2. Add the null-forgiveness operator (!):
t1 = (Table1) serializer.Deserialize(reader)!;
Second, to fix this for other readers that encounter the same situation: I think the overview of Nullable reference types <https://learn.microsoft.com/dotnet/csharp/nullable-references> provides the background needed to understand why these warnings get generated. Do you agree? If so, I'll add a link to that article, and recommend it for anyone unfamiliar with the feature.
We want to keep the error pages as brief as possible. People want to understand the error quickly, and get on with their programming! For that reason, I don't want to replicate the entire overview here. If a paragraph introduction would help, I'll add it.
Thanks for the responses to help us make this better for everyone!
—
Reply to this email directly, view it on GitHub <#34522 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB6M5UEYZY2CN66SQRGWUULW4B4JNANCNFSM6AAAAAAVY7S2PU> .
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
[Enter feedback here]
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
Associated WorkItem - 368775
The text was updated successfully, but these errors were encountered: