のプロパティの最大値を取得します。私は私のクラスのすべてのpropretiesの最大数を取得しようとしているクラス
public class aClass{
public int PropA{ get; set; } = 1;
public int PropB{ get; set; } = 18;
public int PropC{ get; set; } = 25;
}
ここに私のコードです:
public int GetMaxConfiguratableColumns()
{
int _HighestNumber = 0;
PropertyInfo[] _Info = this.GetType().GetProperties();
foreach(PropertyInfo _PropretyInfo in _Info)
{
//I'm lost here!!!!!!!
}
return _HighestNumber;
}
任意の提案?ありがとう!
反射を使用する必要がありますか?異なるアプローチが受け入れられるだろうか? –
最高のプロパティ数はどういう意味ですか? '_Info'には何が入っていますか? – FortyTwo
[C#のリフレクションを使用して文字列からプロパティ値を取得](https://stackoverflow.com/questions/1196991/get-property-value-from-string-using-reflection-in-c-sharp)の重複が考えられます。また[Reflectionを使用してプロパティ値を取得する方法](https://stackoverflow.com/questions/10338018/how-to-get-a-property-value-using-reflection)。 – hatchet