0
クラスからプロパティ名を取得したいとします。
私は、プロパティ名を取得するためにGetType()
を使用していますが、親...を含むシステムのようなプロパティを生成gettypeからユーザー作成のプロパティを取得します。
public class Classtest : Activity
{
public int To { get; set; }
public int From { get; set; }
}
Classtest testclass = new Classtest();
foreach (Activity activity in testclass.Activities)
{
Type type = activity.GetType();
PropertyInfo[] propertyInfo = type.GetProperties();
foreach (var p in propertyInfo)
{
Console.WriteLine(p.Name);
prpoertyCount--;
}
}
出力を示している私だけFrom
とTo
プロパティが、親、名前などの無システムプロパティを必要としています。あなたのケースでは
答えはお役に立ちましたか? – Marusyk