I want to get the static property (or field, which I don't care) inside a generic class, my code looks like this:
public interface IModel{
static string Name {get;}
}
public class MyModel : IModel{
static string Name {get;}
}
public class ViewModel<TModel> where TModel : IModel{
public string GetName(){
return TModel.Name;
}
}
But I got this error:
CS0119: TModel is a type parameter, which is not valid in given context
As I guess, TModel
is a type, not the actual class. So what should I do, or is it just not possible?