Implement IReadOnlyList for State

This commit is contained in:
atef 2023-03-02 15:26:27 +01:00
parent 8c3caa06d5
commit 19188fa430
1 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,8 @@
using System.Collections;
namespace InnovEnergy.Lib.Units;
public readonly struct State
public readonly struct State : IReadOnlyList<String>
{
public IReadOnlyList<String> Values { get; }
@ -25,5 +27,11 @@ public readonly struct State
public static State operator |(State left, State right) => new(left, right);
public IEnumerator<String> GetEnumerator() => Values.GetEnumerator();
public override String ToString() => String.Join("; ", Values);
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public Int32 Count => Values.Count;
public String this[Int32 index] => Values[index];
}