c# and
// The or statement in C# is ||
if (a == b || a == c)
{
// Do something
}
5
2
//The or Symbol Is ||
Thank you!
2
0
4.13
8
// The Or Symbol Is ||
Thank you!
8
0
3.86
7
if (true || false) { //Checks if either side is true
Console.WriteLine("One is true");
}
if (false || false) {
Console.WriteLine("Both are false");
}
//Output:
//One is true
Thank you!
7
0
4.25
4
//the and operator in c sharp is "&&" (hold shift and 6 ;))
if(a == 0 && b == 0)
{
//both a and b is 0
}
Thank you!
4
0
4
2
//The AND (&&) statement will return true if both sides are true,
//otherwise it returns false
if (true && true) { //checks if both sides are true
Console.WriteLine("Both are true");
}
if (false && true) {
Console.WriteLine("One or more is false");
}
//Output:
//Both are true
Thank you!
2
0
Are there any code examples left?
New code examples in category C#