How can my out parameter be nullable?
Not sure what's going on, if anyone can give me a hand on this one
11 Replies
so i have a dictionary called
_names
and the type is Dictionary<string, Ty>
Ty
is a class, name
is a string
The
Try
pattern requires the out parameter to be nullable
If the method returns false
, the out
has to be something, and the only option is a null
ohhh
There's an attribute on it,
[NotNullWhen]
probably, that makes it so that it's not null when the return is true
, yes
But the type is still nullable
That's why, most often, you see people use out var foo
instead of out TheType foo
$tias
hehe
wait it doesn't even work because there's no such entry in the dictionary
oh it's 0, nice
so it's just the default
Yep
thanks
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View