Hope this question is correct, so give you an example. Imagine the following general method:
public abstract class Base : IDisposable { public static IEnumerable<T> GetList<T>() where T : Base {
According to MSDN , the where keyword restricts a parameter of type T Base or inherits from this class.
[...] the where clause may include a base class constraint, which states that the type must have the specified class as the base class (or be that class itself) in order to be used as a type argument for this generic type.
Also this code compiles:
public static T GetFirst() where T : Base {
So, when Base should be returned after the last typeof(T) code, right? Why does Visual Studio then print this warning for me?
warning CS0184: this expression never refers to the provided type (Demo.Base).
generics c # visual-studio type-parameter
Carsten
source share