NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

true

[This is preliminary documentation and subject to change]

In C#, the true keyword can be used as an overloaded operator or as a literal:

true Operator

User-defined types can define a true operator that returns the bool value true to indicate true and returns false otherwise. This is useful for types that represent true, false, and null (neither true nor false), as used in databases.

Such types can be used for the controlling expression in if, do, while, and for statements and in conditional expressions.

If a type defines operator true, it must also define operator false.

A type cannot directly overload the conditional logical operators (&& and ||), but an equivalent effect can be achieved by overloading the regular logical operators and operators true and false (see CLR 7.11.2 User-defined conditional logical operators).

Example

See the example in CLR 11.3.2 Database boolean type.

true Literal

The true keyword is a literal of type bool representing the boolean value true.

Example

using System;
class test {
   public static void Main() {
      bool a = true;
      Console.WriteLine( a ? "yes" : "no" );
   }
}

Output

yes

See Also

C# Keywords | C# Operators | false