Exception/NULL/Error handling advice.

DeserializeAsync clearly returns a nullable generic object. From the picture we can clearly see that the content being passed is not going to be null. Still, DeserializeAsync says that it's possible to return a null, because, let me know if I understood this incorrectly, it's possible that it won't be possible to Deserialize the content (even if its not null) into the specified object, thus it then would return null. Is the only way to check this, to then wrap response in a nullability check and then return it if I don't want to return a null from the method using this code?
1 Reply
Denis
Denis2y ago
In cases you are most certain that the value won't be null and will be parsed, then use the bang operator !. With it you will get rid of the warning However your understanding is most likely correct, you can always check the implementation of the deseiralize method. Look it up online, you should find the .net source browser
Want results from more Discord servers?
Add your server