gpt4 book ai didi

c# - 无法将 'int'隐式转换为 'System.Reflection.BindingFlags'

转载 作者:行者123 更新时间:2023-12-02 11:14:11 29 4
gpt4 key购买 nike

方法

private static bool Properties(string a)
{
BindingFlags bindingFlags = 84;
PropertyInfo property = Bs._Game.GetType().GetProperty(a, bindingFlags);
if (property != null)
{
return (bool)property.GetValue(Bs._Game, null);
}
FieldInfo field = Bs._Game.GetType().GetField(a, bindingFlags);
return field != null && (bool)field.GetValue(Bs._Game);
}

错误是:

Cannot implicitly convert 'int' to 'System.Reflection.BindingFlags'. An explicit conversion exists (are you missing a cast?)

最佳答案

您需要显式转换:

BindingFlags bindingFlags = (BindingFlags)84;

关于c# - 无法将 'int'隐式转换为 'System.Reflection.BindingFlags',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49744153/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com