How do I tell the compiler that the "Thing" in "Thing.VariableProperty" is the type not the instance? Like this it says that my instance of Thing does not contain a definition of VariableProperty.
Or is it wrong of me to use the type name as variable name also?
public interface IThing
{
int Variable { get; }
}
public class Thing : IThing
{
public const string VariableProperty = nameof(Variable);
public int Variable => 1;
}
public class MyClass
{
public IThing Thing = new Thing();
public string GiveMeAString()
{
return "Something about " + Thing.VariableProperty;
}
}
@for string interpolation, which won't work,{Thing.VariableProperty}is just text, meaning that not only would you not get a compiler error from this, it wouldn't even print what you wanted it to print. Clearly, this is not the right code. Can you please post your actual code so that we're not missing something?