I am trying to implement an interface that requires one property, but I do not pay much attention to its type. For instance:
public interface IName
{
dynamic Name {get; set;}
}
Then, if I have a class, I would like to implement an IName interface with a string type:
public class Person : IName
{
public string Name {get; set;}
}
This leads to an error. I know that I can make the interface IName adopt a common argument IName<T>, but it makes me create a bunch of overloaded functions that accept IName<string>, IName<NameObj>, IName<etc>instead of casting within a single function.
How can I require a class to contain a property?
source
share