Static property references non-static method
Posted
by rhj4
on Stack Overflow
See other posts from Stack Overflow
or by rhj4
Published on 2010-04-16T16:18:01Z
Indexed on
2010/04/16
16:23 UTC
Read the original article
Hit count: 478
c#
|static-methods
How can a static property reference a nonstatic method?
Example:
public static int UserID
{
get
{
return GetUserID();
}
}
private int GetUserID()
{
return 1;
}
When I try to compile this, I get the error: "An object reference is required for he non-static field, method or property "GetUserID()"
© Stack Overflow or respective owner