Have a look at the following code:
public class Person
{
private const string MyConst = "SomeValue";
[MyAttribute(MyConst)]
public string Name {get;set;}
}
MyConst
is defined as private
and in my opinion it should not be accessible for MyAttribute. However this code compiles well.
Anyone knows the reason?
Private members are only accessible within the same class body as where they're declared. I guess it's accessible because you're declaring and using it in the same class.