{
Dictionary
foreach (PropertyInfo pi in o.GetType().GetProperties())
{
string s = "";
try
{
object oVal = pi.GetValue(o, null);
if (null != oVal) s = oVal.ToString();
}
catch (Exception ex)
{
s = ex.Message;
}
d.Add(pi.Name, s);
}
return d;
}
Umwandeln des obigen Dictonaries d in Stringliste:
List
bzw. als Stringlist
private List
{
List
foreach (PropertyInfo pi in o.GetType().GetProperties())
{
string s = pi.Name;
try
{
object oVal = pi.GetValue(o, null);
if (null != oVal) s += "=" + oVal.ToString();
}
catch (Exception ex)
{
s += ":" + ex.Message;
}
sl.Add(s);
}
return sl;
}
No comments:
Post a Comment