I’m trying to implement an interface that requires a single property, but I don’t explicitly care what type it is. For example:
public interface IName
{
dynamic Name {get; set;}
}
Then if I have a class I’d like to implement the IName interface with a type of string:
public class Person : IName
{
public string Name {get; set;}
}
This however raises an error. I know I could make the interface IName take a generic arguement IName<T> but that forces me to create a bunch of overloaded functions that take IName<string>, IName<NameObj>, IName<etc> instead of casting within a single function.
How can I require that a class contains a property?
I am unable to test this now, but maybe you could implement the interface explicitly.