I hava a class like this:
public class tbl050701_1391_Fields
{
public static readonly string StateName = \"State Name\";
public static readonly strin
how I can get all properties and their values?
Well to start with, you need to distinguish between fields and properties. It looks like you've got fields here. So you'd want something like:
public static Dictionary<string, string> GetFieldValues(object obj)
{
return obj.GetType()
.GetFields(BindingFlags.Public | BindingFlags.Static)
.Where(f => f.FieldType == typeof(string))
.ToDictionary(f => f.Name,
f => (string) f.GetValue(null));
}