Get static class properties and values via reflection

using System.Reflection;

 static void EnvironmentDemo()
        {
           var pis = typeof(Environment).GetProperties().OrderBy(x=>x.Name).ToList();
            for(int i=0;i)
            {
                Console.WriteLine($"{pis[i].Name}:{pis[i].GetValue(null, null)}");
            }             
        }

 

你可能感兴趣的:(Get static class properties and values via reflection)