DebashshishSaha
New member
- Joined
- Jan 24, 2021
- Messages
- 3
- Programming Experience
- 3-5
c#:
using System;
using System.Collections.Generic;
namespace CovariantAssignment
{
class Program
{
static void Main(string[] args)
{
Apple apple = new Apple() { Name = "" };
}
}
public class Fruit
{
public string Name{ get; set; }
}
public class Apple:Fruit
{
public string Color { get; set; } = "Red";
}
public class Guava : Fruit
{
public string Color { get; set; } = "Green";
}
}
this only resolves if I make the property protected .
Can anyone please explain why ?
Last edited: