Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

true: practical reference

true: practical reference: true is the bool literal that denotes truth.

Version: C# language; verified against C# 14 reference

Syntax

true /* grammar-specific form */

true is the bool literal that denotes truth.

Use the condition directly instead of comparing it with == true when that is clear.

A user-defined type can overload operator true and false with custom logic.

Nullable can also be null and therefore needs explicit handling of a third state.

The complete program actually uses true; its exact expected stdout is True.

Examples

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

Console.WriteLine(true);

Result

True

The complete program actually uses `true`; its exact expected stdout is `True`.

Sources