Basically, what I want to do, is:
public class MySpecialCollection<T>
where T : ISomething { ... }
public interface ISomething
{
public ISomething NextElement { get; }
public ISomething PreviousElement { get; }
}
public class XSomething : ISomething { ... }
MySpecialCollection<XSomething> coll;
XSomething element = coll.GetElementByShoeSize(39);
XSomething nextElement = element.NextElement; // <-- line of interest
... without having to cast nextElement to XSomething. Any ideas? I would have wanted something in the kind of ...
public interface ISomething
{
public SameType NextElement { get; }
public SameType PreviousElement { get; }
}
Thank you in advance!