How To assign Values to Interface Variables with Interface Datatype

Viewed 31

Can any body help me in implementing the below interface, Your prompt response would be appreciated.

public interface IApple
{
IApple Brand { get; }
string Name { get; }
}

This is what i tried to implement

public class AppleChild :IApple 
{

      private string _name;
      private string _brand;
      public AppleChild()
 {
    _brand = "sad";
    _name = "adsa";


   }
  IApple IApple.Brand => _brand; --getting error here it says Cannot convert type string 
to IApple
  string IApple.Name {
   get
   {
       return _name;
   }
   }
1 Answers

Surely this:

IApple Brand { get; }

should be this:

string Brand { get; }
Related