I'm wondering I can't reach static class field from instance variable
class aa
{
public static string b = "bb";
}
Console.WriteLine(aa.b); //fine
aa f = new aa();
f.b //error
Why? Do I make something wrong?
I'm wondering I can't reach static class field from instance variable
class aa
{
public static string b = "bb";
}
Console.WriteLine(aa.b); //fine
aa f = new aa();
f.b //error
Why? Do I make something wrong?
Outside you can get a static field by ClassName.StaticVariable
, but inside the class it is similar to other instance variables. This is because static variables are owned by class, not a specific instance.