Two generic classes C and D - with compiler errors. | Lecture 11 - slide 11 : 21 Program 2 |
/* Example from Hansen and Sestoft: C# Precisely */ class C<T>{ // Compiler Error message: // Cannot convert null to type parameter 'T' because it could // be a value type. Consider using 'default(T)' instead. T f = null; } class D<U>{ // Compiler Error message: // The type 'U' must be a non-nullable value type in order to use // it as parameter 'T' in the generic type or method // 'System.Nullable<T>' U? f; } |