Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Rikitav/Unified.Firmware/llms.txt

Use this file to discover all available pages before exploring further.

BootOptionIndex is a lightweight, immutable value type in the Unified.Firmware namespace that wraps a ushort index identifying a specific UEFI Boot#### NVRAM variable. Rather than passing raw ushort values through the API — which carry no semantic meaning on their own — BootOptionIndex makes intent explicit and provides a canonical string representation in the Boot#### format used by the firmware (e.g. index 3 becomes "Boot0003"). Because the struct defines implicit conversions both to and from ushort, you can pass a numeric literal anywhere a BootOptionIndex is expected without any explicit cast.

Namespace

namespace Unified.Firmware;

Constructor

public BootOptionIndex(ushort index)
index
ushort
required
The zero-based 16-bit unsigned integer index of the target Boot#### NVRAM variable. Valid range: 0x00000xFFFF.
BootOptionIndex idx = new BootOptionIndex(3);
Console.WriteLine(idx); // Boot0003

Interfaces Implemented

InterfacePurpose
IEquatable<BootOptionIndex>Value equality against another BootOptionIndex.
IEquatable<ushort>Value equality against a raw ushort.
IComparable<BootOptionIndex>Ordering against another BootOptionIndex.
IComparable<ushort>Ordering against a raw ushort.

Methods

ToString

public override string ToString()
Returns the Boot#### string representation of the index. The format string is $"Boot{_index:X4}" — the Boot prefix followed by the index value formatted as exactly four uppercase hexadecimal digits with leading zeros. Returns: string — for example, index 3"Boot0003", index 255"Boot00FF", index 4096"Boot1000".
BootOptionIndex idx = new BootOptionIndex(3);
string name = idx.ToString(); // "Boot0003"

Equals

public bool Equals(BootOptionIndex other)
public bool Equals(ushort other)
Compares the wrapped ushort value for equality.
other
BootOptionIndex or ushort
required
The value to compare against.
Returns: booltrue if the underlying index values are equal.

CompareTo

public int CompareTo(BootOptionIndex other)
public int CompareTo(ushort other)
Compares the wrapped ushort values using standard numeric ordering. Returns: int — negative if this instance is less than other, zero if equal, positive if greater.

GetHashCode

public override int GetHashCode()
Returns the hash code of the underlying ushort value. Safe to use as a dictionary key.

Operators

OperatorSignatureDescription
==BootOptionIndex == BootOptionIndextrue when both wrapped indices are equal.
!=BootOptionIndex != BootOptionIndextrue when the wrapped indices differ.
BootOptionIndex a = new BootOptionIndex(2);
BootOptionIndex b = new BootOptionIndex(2);

Console.WriteLine(a == b); // True
Console.WriteLine(a != b); // False

Implicit Conversions

BootOptionIndex defines three implicit conversions so that you can use it interchangeably with ushort literals or string variables anywhere the API expects it.
ConversionDirectionNotes
ushortBootOptionIndexWideningLets you pass a ushort literal (e.g. 0x0003) wherever a BootOptionIndex is required, with no explicit cast.
BootOptionIndexushortNarrowingExtracts the raw index value.
BootOptionIndexstringCalls ToString(), producing "Boot####" with four uppercase hex digits.
// ushort → BootOptionIndex: no cast required
FirmwareBootOption option = FirmwareBootService.ReadLoadOption(0x0003);

// BootOptionIndex → ushort
BootOptionIndex idx = new BootOptionIndex(5);
ushort raw = idx;          // 5
Console.WriteLine(raw);   // 5

// BootOptionIndex → string (implicit, via Console.WriteLine overload)
Console.WriteLine(idx);   // Boot0005

Usage Patterns

Passing a literal index

Because ushort implicitly converts to BootOptionIndex, you can pass a hex literal directly to any FirmwareBootService method:
// Reads Boot0003 — the ushort literal 0x0003 is converted automatically
FirmwareBootOption option = FirmwareBootService.ReadLoadOption(0x0003);
Console.WriteLine(option.Description);

Working with BootOrder

FirmwareBootService.LoadOrder returns a BootOptionIndex[]. Iterate or index into it directly:
BootOptionIndex[] order = FirmwareBootService.LoadOrder;

foreach (BootOptionIndex idx in order)
{
    FirmwareBootOption entry = FirmwareBootService.ReadLoadOption(idx);
    Console.WriteLine("{0}: {1}", idx, entry.Description);
    // Prints lines like: Boot0000: Windows Boot Manager
}

Printing the formatted name

The implicit string conversion and ToString() both produce "Boot####" with four uppercase hex digits:
BootOptionIndex idx = new BootOptionIndex(3);

// All three lines print "Boot0003"
Console.WriteLine(idx);
Console.WriteLine(idx.ToString());
string s = idx; // implicit conversion
Console.WriteLine(s);

Comparing indices

BootOptionIndex current = FirmwareBootService.CurrentLoadOptionIndex;

if (current == (BootOptionIndex)0x0000)
    Console.WriteLine("Booted from Boot0000");

// Comparing against a raw ushort using IEquatable<ushort>
if (current.Equals((ushort)0x0001))
    Console.WriteLine("Booted from Boot0001");
BootOptionIndex is a readonly struct. All instances are value types and are copied by value. Assigning one to a variable or passing it to a method never aliases the original.

Build docs developers (and LLMs) love