私は次のコードを持っています:
Tuple<string, string, Type, ParameterInfo[]> method = (Tuple<string, string, Type, ParameterInfo[]>)(comboBox1.SelectedItem);
if (comboBox2.SelectedIndex - 1 >= 0)
{
if (method.Item4[comboBox2.SelectedIndex - 1].ParameterType.BaseType == typeof(Enum))
{
foreach (object type in Enum.GetValues(method.Item4[comboBox2.SelectedIndex - 1].ParameterType))
{
Console.WriteLine(type);
}
MessageBox.Show("This looks like an auto-generated type; you shouldn't set it to anything.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
}
else if (Nullable.GetUnderlyingType(method.Item4[comboBox2.SelectedIndex - 1].ParameterType) != null)
{
if (Nullable.GetUnderlyingType(method.Item4[comboBox2.SelectedIndex - 1].ParameterType).BaseType == typeof(Enum))
{
MessageBox.Show("This looks like an auto-generated type; you shouldn't set it to anything.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
}
}
}
else ifステートメントで、comboBox2.SelectedIndexが1の場合、method.Item4 [0]のオブジェクトは常にNullable型であるにもかかわらず、常にnullを返すことに気付きました。なぜnullを返すのでしょうか。真剣に、私はそこにブレークポイントを置き、Item4では、インデックス0のオブジェクトを次のように表示します。
[0] = {System.Nullable`1 [CarConditionEnum]&carCondition}
...そしてインデックス1で:
[1] = {Boolean&carConditionSpecified}