我有这样的逻辑。
if( (value1 !="0" || value2!="0") && value3=="0")
{
value3=string.empty;
}
类似地
if( (value2 !="0" || value3!="0") && value1=="0")
{
value1=string.empty;
}
if( (value1 !="0" || value3!="0") && value2=="0")
{
value2=string.empty;
}
使用linq编写上述逻辑的最佳方法是什么?没有重复的逻辑
我的想法是推动他们通过收藏字典。但是逻辑不完全明确
答案 0 :(得分:1)
您可以使用一个行函数来解决此问题:
className={props.formProps.errors[props.name] && props.formProps.touched[props.name] ? 'is-invalid form-control' : 'form-control'}
用法:
bool test(string[] orConds, string andCond, string val) => orConds.Any(s => s != val) && andCond == val;