I am trying to create a class with a single property which can be referenced globally within my app to store the FB access token. The code below is what I’ve got so far;
public static class FBAccessTokenClass
{
private string _accessToken = "";
public static string FBAccessToken
{
get { return _accessToken; }
set { _accessToken = value; }
}
}
The above code is giving me the following error:
An object reference is required for the non-static field, method, or property
I’m fairly new to c# and any help would be appreciated.
Change
to
The static keyword means that the veriable isn’t bound to an object of type FBAccessTokenClass, but rather belongs to the FBAccessTokenClass type itself.
Moreover, are you sure you should be using a static class for this?