Share via


true Operator (C# Reference) 

Returns the bool value true to indicate true and returns false otherwise when defined by a user-defined type. 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.

C# Language Specification

For more information, see the following sections in the C# Language Specification:

  • 10.9.1 Unary operators

  • 7.11.2 User-defined conditional logical operators

  • 7.16 Boolean expressions

See Also

Reference

C# Keywords
C# Operators
false (C# Reference)

Concepts

C# Programming Guide

Other Resources

C# Reference