1
我在这里有一个错误代码,因为我无法检查字符串是否等于string []。C#Linq - 如果输入不等于任何字符串[]
public void SetCh1Probe(string input)
{
string[] option= {"1:1", "1:10", "1:100"}
//I wanna check if input is equal to any of the string array
if (input != option.Any(x => x == option))
{
MessageBox.Show("Invalid Input");
}
else
{
//Proceed with other stuffs
}
}
我会有很多这样的方法,每个都有不同的string[] options
。我真的想要一个整洁的模板,我可以使用其余的方法。任何人都可以帮忙吗?
我相信'setting.Any'应该是'option.Any'如果我明白你的问题的正确 –
可能的复制[检查是否值是一个数组(C#)](HTTP://计算器。 com/questions/13257458/check-if-a-value-is-an-an-array-c) –
是的,那是一个错字。无论如何,抱歉的重复。我无法相信在发布之前我找不到该线索。 –