Nullable reference types with generic return type
问题 I'm playing around a bit with the new C# 8 nullable reference types feature, and while refactoring my code I came upon this (simplified) method: public T Get<T>(string key) { var wrapper = cacheService.Get(key); return wrapper.HasValue ? Deserialize<T>(wrapper) : default; } Now, this gives a warning Possible null reference return which is logical, since default(T) will give null for all reference types. At first I thought I would change it to the following: public T? Get<T>(string key) But