C
C#•13mo ago
Paulvv

Warning: "Game" may be null here

I can't find a way to set this object as nullable. I want the Game object to be a choice not a required one.
No description
No description
7 Replies
Jimmacle
Jimmacle•13mo ago
even if you set it as nullable this code will always throw an exception
Thinker
Thinker•13mo ago
Well you're not setting Game
Jimmacle
Jimmacle•13mo ago
you need to provide a non-null default value for Game or add logic to conditionally create a Game if they provide a game name etc
Thinker
Thinker•13mo ago
You're trying to set Game.Name while Game while is unconditionally null
Jimmacle
Jimmacle•13mo ago
the way your code is written now, it doesn't look like having a Game is optional because the constructor always tries to do something with it
Angius
Angius•13mo ago
In other words, you have a garage, the garage is empty, and you say "paint this car green"
No description
Paulvv
PaulvvOP•13mo ago
Thank you guys so much. It works now! 😀 I think I've stared to long to the screen. Enough coding for me today.
Want results from more Discord servers?
Add your server