Share or in lambda c#

phamnhasnow

New member
## hoặc trong lambda c#

Hoặc (hoặc, nếu không) là một toán tử logic trả về giá trị boolean là true nếu một trong hai toán hạng của nó là đúng.Trong C#, toán tử OR được biểu diễn bởi ||biểu tượng.

Đoạn mã sau hiển thị cách sử dụng hoặc toán tử để kiểm tra xem một biến có bằng 1 hoặc 2:

`` `C#
int x = 1;

if (x == 1 || x == 2)
{
// Làm việc gì đó
}
`` `

Toán tử OR cũng có thể được sử dụng để kiểm tra xem một biến không bằng giá trị.Ví dụ: đoạn mã sau kiểm tra nếu biến `x` không bằng 3:

`` `C#
int x = 1;

if (x! = 3)
{
// Làm việc gì đó
}
`` `

Toán tử OR có thể được sử dụng trong bất kỳ biểu thức nào cần giá trị boolean.Ví dụ: đoạn mã sau sử dụng toán tử hoặc toán tử để kiểm tra xem một biến có lớn hơn hoặc bằng 10 và nhỏ hơn hoặc bằng 20:

`` `C#
int x = 15;

if (x> = 10 && x <= 20)
{
// Làm việc gì đó
}
`` `

### Bài viết tham khảo

* [C# toán tử] (C# operators and expressions - List all C# operators and expression - C#)
* [Hoặc nhà điều hành] (https://docs.microsoft.com/en-us/dotnet/csharp/langle-reference/operators/or-operator)

### hashtags

* #csharp
* #Lambda
* #Operators
* #Người điều hành logic
* #Hoặc
=======================================
## OR in Lambda C#

OR (or, otherwise) is a logical operator that returns a Boolean value of true if either of its operands is true. In C#, the OR operator is represented by the || symbol.

The following code snippet shows how to use the OR operator to check if a variable is equal to either 1 or 2:

```c#
int x = 1;

if (x == 1 || x == 2)
{
// Do something
}
```

The OR operator can also be used to check if a variable is not equal to a value. For example, the following code snippet checks if the variable `x` is not equal to 3:

```c#
int x = 1;

if (x != 3)
{
// Do something
}
```

The OR operator can be used in any expression where a Boolean value is required. For example, the following code snippet uses the OR operator to check if a variable is greater than or equal to 10 and less than or equal to 20:

```c#
int x = 15;

if (x >= 10 && x <= 20)
{
// Do something
}
```

### Reference Articles

* [C# Operators](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/)
* [OR Operator](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/or-operator)

### Hashtags

* #csharp
* #Lambda
* #Operators
* #Logical-operators
* #or
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top