✅ What is the syntax for generics in methods signature
Hello guys, consider the following:
Declaration:
Can someone explain what T refers to please, is it the return type or the type that the argument can take? I'm always confuse by that... what if we can have multiple generic parameters? How would we represent them?
Is there a syntax to follow? for example in the
TraverseBreadthFirst<T>(T, Func<T, IEnumerable<T>>)Declaration:
public static IEnumerable<T> TraverseBreadthFirst<T>(T root, Func<T, IEnumerable<T>> childrenSelector)Can someone explain what T refers to please, is it the return type or the type that the argument can take? I'm always confuse by that... what if we can have multiple generic parameters? How would we represent them?
Is there a syntax to follow? for example in the
Func<T, IEnumerable<T>> delegate type, I know that T is the argument and IEnumerable<T>> is the return type