In java I have a class:
static public class PCB_Node<T extends PCB_Node<T>> implements Iterable<T> {
public T parent;
public T first_child;
public T next_brother;
public Iterator<T> iterator() {
return get_iterator((T)this);
}
}
static public <T extends PCB_Node<T>> Iterator<T> get_iterator(T e) {
...
}
I attempt to do port this to c#, in which I have very little experience.
I defined the class like this:
public class PCB_Node<T> where T : PCB_Node<T>, IEnumerable<T> {
public T parent;
public T first_child;
public T next_brother;
public IEnumerator<T> GetEnumerator() {
return get_iterator((T)this); // << not sure about this, but that also depends on if it is possible
}
}
I have problems with doing the following java line in c#: static public <T extends PCB_Node<T>> Iterator<T> get_iterator(T e) {. And I'm not sure if it's even possible, cause so far, I can't find anything about it.
I know I can implement GetEnumerator in the class itself instead of redirecting it to some static method, but I prefer it this way.
I guess this is what I want:
static public IEnumerable<T> get_iterator(T e) where T : PCB_Node<T> {
Is something like that possible?
staticonly applies to nested classes