---
title: Interpret a string as a boolean and render booleans as flags
summary: Convert between truthy flag strings and boolean values.
status: draft
owner: saif-docgen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common
reference_type: package
operation_id: OP-031
trigger: Caller converts between flag strings (from files, code tables, or UI) and `bool`
---

# Interpret a string as a boolean and render booleans as flags

Convert between truthy flag strings and boolean values, triggered when caller converts between flag strings (from files, code tables, or UI) and `bool`.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-031 |
| **Trigger** | Caller converts between flag strings (from files, code tables, or UI) and `bool` |
| **Inputs** | `string` / `bool` |
| **Outputs** | `bool` / `string` |
| **Primary components** | ``StringExtensions.ToBoolean(this string)`; `BooleanExtensions.ToY_N_String` / `ToYesNoString` / `ToOnOffString`` |
| **Entry point** | `Common/SAIF.Common/Extensions/StringExtensions.cs` |

## Steps

1. `ToBoolean` returns `false` immediately for a null input. ([BR-072](../business-rules.md#br-072-a-string-is-truthy-only-when-it-uppercases-to-one-of-y%2C-yes%2C-true%2C-1%2C-or-on))
2. Otherwise uppercase the value and test membership in the fixed truthy set `{"Y","YES","TRUE","1","ON"}` via `IEnumerableExtensions.IsIn`. Anything else is `false`. ([BR-072](../business-rules.md#br-072-a-string-is-truthy-only-when-it-uppercases-to-one-of-y%2C-yes%2C-true%2C-1%2C-or-on))
3. `ToY_N_String` renders `true` as `"Y"` and `false` as `"N"`. ([BR-073](../business-rules.md#br-073-booleans-render-to-flags-as-y%2Fn%2C-yes%2Fno%2C-or-on%2Foff-depending-on-the-method-chosen))
4. `ToYesNoString` renders `"YES"` / `"NO"` (uppercase); `ToOnOffString` renders `"On"` / `"Off"` (mixed case). ([BR-073](../business-rules.md#br-073-booleans-render-to-flags-as-y%2Fn%2C-yes%2Fno%2C-or-on%2Foff-depending-on-the-method-chosen))

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start(["Caller converts between<br>flag strings and bool"]) --> Dir{"Direction of<br>conversion?"}
	Dir -->|"string -> bool"| C1{"ToBoolean input<br>is null?"}
	C1 -->|Yes| False([Return false])
	C1 -->|No| S1["Uppercase value, test<br>membership in {Y, YES,<br>TRUE, 1, ON}"]
	S1 --> C2{"Value is in<br>truthy set?"}
	C2 -->|Yes| True([Return true])
	C2 -->|No| False2([Return false])
	Dir -->|"bool -> string"| Method{"Which render<br>method is called?"}
	Method -->|ToY_N_String| S2(["Render 'Y' or 'N'"])
	Method -->|ToYesNoString| S3(["Render 'YES' or 'NO'"])
	Method -->|ToOnOffString| S4(["Render 'On' or 'Off'"])
	True --> End([Result returned])
	False --> End
	False2 --> End
	S2 --> End
	S3 --> End
	S4 --> End
```

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `Common/SAIF.Common/Extensions/StringExtensions.cs`
- `Common/SAIF.Common/Extensions/BooleanExtensions.cs`
