PKHeX/PKHeX.Core/Game/ComboItem.cs

31 lines
818 B
C#
Raw Normal View History

using System.Collections.Generic;
namespace PKHeX.Core
2016-07-09 15:34:38 -07:00
{
/// <summary>
/// Key Value pair for a displayed <see cref="string"/> and underlying <see cref="int"/> value.
/// </summary>
public struct ComboItem
2016-07-09 15:34:38 -07:00
{
public string Text { get; set; }
public int Value { get; set; }
}
public static class ComboItemExtensions
{
public static string[] GetArray(this IReadOnlyList<ComboItem> list)
{
var max = list[list.Count - 1].Value;
return GetArray(list, max);
}
public static string[] GetArray(this IEnumerable<ComboItem> list, int max)
{
var arr = new string[max + 1];
foreach (var item in list)
arr[item.Value] = item.Text;
return arr;
}
}
2016-07-09 15:34:38 -07:00
}