/// <summary> /// Get the index of the table element with particular text /// </summary> /// <param name="text"></param> /// <returns></returns> public int GetIndex(String text) { if (!DataList.Any()) { throw new Exception(String.Format("There are no data elements.")); } return(ValueList.IndexOf(text.Trim())); }
public static void IndexOfTest() { var valueList = new ValueList <int>(new int[] { 1, 2, 3 }); Assert.That(() => valueList.IndexOf(1), Is.EqualTo(0) ); Assert.That(() => valueList.IndexOf(4), Is.EqualTo(-1) ); valueList = new ValueList <int>(); Assert.That(() => valueList.IndexOf(0), Is.EqualTo(-1) ); }
/// <exception cref="BadSyntaxException"> /// The name does not fit to the syntax. /// </exception> /// <exception cref="ReservedNameException"> /// The name is a reserved name. /// </exception> public EnumItem ModifyValue(EnumItem value, string declaration) { int index = ValueList.IndexOf(value); if (index >= 0) { EnumItem newValue = EnumItem.LoadFromString(declaration); for (int i = 0; i < ValueList.Count; i++) { if (i != index && ValueList[i].Name == newValue.Name) { throw new ReservedNameException(newValue.Name); } } ValueList[index] = newValue; return(newValue); } else { return(value); } }
public virtual int IndexOf(T value) => ValueList.IndexOf(value);