Skip to main content

ProtocolRange

readonly struct

Represents an inclusive range of protocol numbers.

Declaration

public readonly struct ProtocolRange
NamespaceMcProtoNet.Protocol
AssemblyMcProtoNet.Protocol.dll
Sourcesrc/McProtoNet.Protocol/ProtocolRange.cs#L6 ↗

Constructors

SignatureDescription
ProtocolRange(int from, int to)Initializes a new instance of the ProtocolRange structure with the specified bounds.

ProtocolRange(int, int)

public ProtocolRange(int from, int to)

Initializes a new instance of the ProtocolRange structure with the specified bounds.

Parameters: from (Int32), to (Int32)

Properties

SignatureDescription
int FromGets the lowest protocol number in the range.
int ToGets the highest protocol number in the range.

From

public int From { get; }

Gets the lowest protocol number in the range.

Returns: Int32

To

public int To { get; }

Gets the highest protocol number in the range.

Returns: Int32

Methods

SignatureDescription
static bool IsSupported(ProtocolRange[] ranges, int protocol)Determines whether the specified protocol number falls within any of the specified ranges.
string ToString()Returns the string representation of the range.

IsSupported(ProtocolRange[], int)

public static bool IsSupported(ProtocolRange[] ranges, int protocol)

Determines whether the specified protocol number falls within any of the specified ranges.

Parameters: ranges (ProtocolRange[]), protocol (Int32)

Returns: Boolean - <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool"&gt;true&lt;/a> if <code class="paramref">protocol</code> falls within one of <code class="paramref">ranges</code>; otherwise, <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool"&gt;false&lt;/a>.

ToString()

public override string ToString()

Returns the string representation of the range.

Returns: String - The single protocol number when both bounds are equal; otherwise, the two bounds separated by a hyphen.