why can't a static member be reached through an instance name?
Posted
by reinier
on Stack Overflow
See other posts from Stack Overflow
or by reinier
Published on 2010-03-19T12:13:35Z
Indexed on
2010/03/19
12:21 UTC
Read the original article
Hit count: 322
say I have:
class Test
{
public static int Hello = 5;
}
This obviously works:
int j = Test.Hello;
But why should this not work?
Test test = new Test();
int j = test.Hello;
The instance could not have a member equally named, so I don't see how this could be ambiguous or unresolvable for a compiler.
Anyone any idea why this is?
© Stack Overflow or respective owner