I assume this refers to your previous list of questions ; if so, then the example I provided is an extension method and will be:
public static class LinkedListUtils { // name doesn't matter, but must be // static and non-generic public static IEnumerable<T> Reverse<T>(this LinkedList<T> list) {...} }
This utility class does not have to match the consumption class, but extension methods are how you can use it as list.Reverse()
If you do not want this to be an extension method, you can simply make it a local static method - just take "this" from the first parameter:
public static IEnumerable<T> Reverse<T>(LinkedList<T> list) {...}
and use as:
foreach(var val in Reverse(list)) {...}
source share