help
Root Question Message
if ("any" is "item1" or "item2" or "any")
{
Console.WriteLine("okay");
}
if ("any" == "item1" || "item2" || "any") // "any" == "item1" || "any" == "item2" will be corrent but really bad readable
{
Console.WriteLine("okay");
}
or
to test against for different matches. The second code block uses the binary conditional logic operators which only work on booleans (true
or false
).||
's. Take a look at sharplab decompile:internal class Program
{
private static void <Main>$(string[] args)
{
string text = "any";
if (text == "item1" || text == "item2" || text == "any")
{
Console.WriteLine("okay");
}
}
}