public static int LastIndexOf(object obj, object entry) { if (obj is IList) { IList a = (IList)obj; for (int i = a.Count - 1; i >= 0; --i) { if (a[i].Equals(entry)) { return(i); } } } else { IDeque a = (IDeque)obj; return(a.LastIndexOf(entry)); } return(-1); }