C# – Get values of static properties from static class

The problem is that property1..3 are not properties, but fields.

To make them properties change them to:

private static string _property1 = "NumberOne";
public static string property1
{
  get { return _property1; }
  set { _property1 = value; }
}

Or use auto properties and initialize their values in the static constructor of the class:

public static string property1 { get; set; }

static MyStaticClass()
{
  property1 = "NumberOne";
}

…or use myType.GetFields(...) if fields are what you want to use.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)