null
is being assigned to an entity that is non-nullable CS-W1028null
assigned to non-nullable 49
50 // CS-R1047: Use `T?` instead of `Nullable<T>`.
51 // https://deepsource.io/directory/analyzers/csharp/issues/CS-R1047
52 Nullable<int> i = null; 53
54 // CS-R1024: Use `null-coalescing` operator, i.e. rewrite as `i ?? 1`.
55 // https://deepsource.io/directory/analyzers/csharp/issues/CS-R1024
The ?
operator is used to denote that an entity is nullable
. Nullables are those whose values can be set to null
. Because the entity in this case is not a nullable and is being initialized and set to null
, it is recommended that you either mark it as a nullable
, or initialize it with a proper non-null value.
Foo f = null;
// Make `f` nullable
Foo? f = null;
// Alternately
Foo f = new Foo();