我需要测试字符串数组中的所有值是否仅为"0“或"1”,并尝试了以下代码,但没有成功:
bool isBool = Array.TrueForAll(str, val => val.Trim() == "0" || val.Trim() == "1");
和
bool isBool = str.All(val => val.Trim() == "0" || val.Trim() == "1");
因为我使用了||条件,所以有没有不同的方法?
https://stackoverflow.com/questions/54815365
复制相似问题