面试题答案
一键面试using System;
using System.Reflection;
class Program
{
static void Main()
{
Type type = typeof(SampleClass);
PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo property in properties)
{
Console.WriteLine(property.Name);
}
}
}
class SampleClass
{
public string Property1 { get; set; }
public int Property2 { get; set; }
}