I’ve recently started learning C#. I just learned about properties and decided to make a simple program in order to understand them more.
this is the code I wrote:
class Dog
{
private int weight;
private string colour;
public string colour { get; set; }
public Dog(int theWeight, string theColour)
{
weight = theWeight;
colour = theColour;
}
}
And i get an ambiguity error.
As far a I understand, this shouldn’t happen.
You have a field and a property with the same name
colour. That is why the compiler produces an error.