/// <summary>
/// 获得 实体对象的 key、 value
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="t"></param>
public static void ConvertToFormField<T>(T t)
{
if (t == null)
{
return;
}
System.Reflection.PropertyInfo[] properties = t.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
if (properties.Length <= 0)
{
return;
}
foreach (System.Reflection.PropertyInfo item in properties)
{
string name = item.Name;
object value = item.GetValue(t, null);
if (item.PropertyType.IsValueType || item.PropertyType.Name.StartsWith("String"))
{
if (null == value)
{
continue;
}
System.Console.Out.Write(name);
System.Console.Out.WriteLine("\t" + value);
}
}
}