The return type of the members on an Interface Implementation must match exactly the interface definition?

前端 未结 6 1696
栀梦
栀梦 2020-12-05 11:58

According to CSharp Language Specification.

An interface defines a contract that can be implemented by classes and structs. An interface does not p

6条回答
  •  难免孤独
    2020-12-05 12:43

    You can do something like this:

     interface ITest
    {
        IEnumerable Integers { get; set; }
    }
    
    class Test : ITest
    {
        public IEnumerable Integers { get; set; }
    
        public Test()
        {
            Integers = new List();
        }
    }
    

提交回复
热议问题