Click here to Skip to main content
15,884,472 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
PIEBALDconsult16-Dec-20 3:00
mvePIEBALDconsult16-Dec-20 3:00 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
BabyYoda16-Dec-20 3:20
BabyYoda16-Dec-20 3:20 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
Marc Clifton16-Dec-20 3:35
mvaMarc Clifton16-Dec-20 3:35 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
Jörgen Andersson16-Dec-20 4:30
professionalJörgen Andersson16-Dec-20 4:30 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
lmoelleb16-Dec-20 7:07
lmoelleb16-Dec-20 7:07 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
Jörgen Andersson16-Dec-20 4:27
professionalJörgen Andersson16-Dec-20 4:27 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
Gerry Schmitz16-Dec-20 5:32
mveGerry Schmitz16-Dec-20 5:32 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
lmoelleb16-Dec-20 7:24
lmoelleb16-Dec-20 7:24 
Returning null: Everything is fine, but the stuff you asked for does not exists which is expected to happen.
Throwing an exception: There is a problem - it is stopping me from getting the stuff you asked for, or it is really freaking weird it is missing - your data model probably exploded.

Two VERY different situations and if you handle them both the same - ehh... well.. ehhh... yikes.

Unfortunately it is not always clear-cut which is best, so you often end up wishing the API you use does "the opposite" (Queue.Dequeue, I am looking at you, it's not a freaking problem a queue is empty - it is vary often the desirable state). Some API's have both (TryDequeue would be nice).

But at least now I can look at the return type and know right away if whatever I call can return null or not.

Don't follow your comment on Linq. I think you have a misunderstanding of the nullable type system. All that will change is the return type of FirstOrNull will be of the nullable type - so if it is strings, FirstOrNull return type will be string? instead of just string.

Normally the compiler is on top of it, and will not bother you at all if you check for null before assigning it to a non-nullable string. If the compiler bothers you, maybe ask yourself if you really want to proceed with some code the compilers type system can't understand. If you do, simply override the null check with a !
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
harold aptroot16-Dec-20 20:24
harold aptroot16-Dec-20 20:24 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
Lorenzo Bertolino16-Dec-20 20:36
professionalLorenzo Bertolino16-Dec-20 20:36 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
Mark Quennell16-Dec-20 22:32
Mark Quennell16-Dec-20 22:32 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
Rob Philpott16-Dec-20 22:41
Rob Philpott16-Dec-20 22:41 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
Mark Quennell16-Dec-20 22:50
Mark Quennell16-Dec-20 22:50 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
Rob Philpott16-Dec-20 23:01
Rob Philpott16-Dec-20 23:01 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
Mark Quennell16-Dec-20 23:09
Mark Quennell16-Dec-20 23:09 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
Rob Philpott16-Dec-20 23:18
Rob Philpott16-Dec-20 23:18 
GeneralRe: C Sharps - how are you getting on with nullable reference types? Pin
Mark Quennell16-Dec-20 23:22
Mark Quennell16-Dec-20 23:22 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
Thornik17-Dec-20 8:32
Thornik17-Dec-20 8:32 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
zezba900018-Dec-20 11:02
zezba900018-Dec-20 11:02 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
AnotherKen18-Dec-20 20:08
professionalAnotherKen18-Dec-20 20:08 
AnswerRe: C Sharps - how are you getting on with nullable reference types? Pin
Adam David Hill27-Dec-20 3:02
professionalAdam David Hill27-Dec-20 3:02 
GeneralI have the feeling they do it on purpose... Pin
Kornfeld Eliyahu Peter15-Dec-20 22:00
professionalKornfeld Eliyahu Peter15-Dec-20 22:00 
GeneralRe: I have the feeling they do it on purpose... Pin
W Balboos, GHB16-Dec-20 2:51
W Balboos, GHB16-Dec-20 2:51 
GeneralWSO CCC OTD 2020-12-16 Pin
Sandeep Mewara15-Dec-20 20:52
mveSandeep Mewara15-Dec-20 20:52 
GeneralRe: WSO CCC OTD 2020-12-16 - You win! Pin
OriginalGriff16-Dec-20 0:57
mveOriginalGriff16-Dec-20 0:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.