如何使用LINQ实现与以下代码相同的结果?
如果字符串与字符串列表中的任何字符串不同,它将返回true。
public static bool MasterPlantDifferentFromDetailPlant(string mrNumber)
{
string masterPlant = t_MT_MTInfo.GetMaterialRequestPlant(mrNumber);
List<string> detailPlants = t_MT_MTItem.GetPlants(mrNumber);
bool differentPlant = false;
foreach (string plant in detailPlants)
{
if (string.Compare(masterPlant.Trim(), plant.Trim(), StringComparison.OrdinalIgnoreCase) != 0)
{
differentPlant = true;
break;
}
}
return differentPlant;
}
答案 0 :(得分:4)
cPickle.dumps(obj, protocol=cPickle.HIGHEST_PROTOCOL)
答案 1 :(得分:0)
试试这个;
public static bool MasterPlantDifferentFromDetailPlant(string mrNumber)
{
string masterPlant = t_MT_MTInfo.GetMaterialRequestPlant(mrNumber);
List<string> detailPlants = t_MT_MTItem.GetPlants(mrNumber);
return !detailPlants.All(x => string.Equals(masterPlant.Trim(), x.Trim(), StringComparison.OrdinalIgnoreCase));
}