Imagine I have a class structure similar to this:
public interface IArbitraryQualifier {
int Qualification { get; }
}
public class ArbitraryQualifier : IArbitraryQualifier {
public const int MIN_QUALITY = 1;
public int Qualification { get; }
}
public class Person {
public IArbitraryQualifier ArbitraryQualifier { get; }
public bool AmIARealBoy
{
get
{
return this.ArbitraryQualifier.Qualification >= ArbitraryQualifier.MIN_QUALITY;
}
}
}
How do I reference the constant field MIN_QUALITY
in class ArbitraryQualifier
from within class Person
? It keeps generating error IDE0009 ("... does not contain a definition for ...") which suggests I "add 'this' or 'me' qualification".
If I rename the property or the concrete class it works just fine, but I don't want to (I am using a boilerplate class named the same as the property).
Note that this also occurs for abstract classes and generic types, but not concrete types. For example, there is no compilation error here:
public class ArbitraryQualifier {
public const int MIN_QUALITY = 1;
public int Qualification { get; }
}
public class Person {
public ArbitraryQualifier ArbitraryQualifier { get; }
public bool AmIARealBoy
{
get
{
return this.ArbitraryQualifier.Qualification >= ArbitraryQualifier.MIN_QUALITY;
}
}
}
Also, why does this compile when the others do not?