I want to easily be able to choose what it returns so I made this. How do you properly do this?Code:public class RoomCollection : List<Room> { public T IndexOfName<T>(string name) { if (!(typeof(T) == typeof(int)) && !(typeof(T) == typeof(Room))) throw new Exception("Invalid generic parameter!"); for (int i = 0; i < this.Count; i++) { if (this[i].SiteID == name) { if (typeof(T) == typeof(int)) return (T)(object)i; return (T)(object)this[i]; } } if (typeof(T) == typeof(int)) return (T)(object)-1; return (T)(object)null; } }




Reply With Quote