P
puzzlecracker
In the example below ( it's taken off Jon's blogs), what does this
keyword in the parameter list mean?
Also, why do we need to do specify generic T here WithLogging<T>?
wouldn't type be derived from IEnumerable<T> ?
using System;
using System.Collections.Generic;
public static class Extensions
{
public static IEnumerable<T> WithLogging<T>(this IEnumerable<T>
source,
string name)
{
foreach (T element in source)
{
Console.WriteLine("{0}: {1}", name, element);
yield return element;
}
}
}
keyword in the parameter list mean?
Also, why do we need to do specify generic T here WithLogging<T>?
wouldn't type be derived from IEnumerable<T> ?
using System;
using System.Collections.Generic;
public static class Extensions
{
public static IEnumerable<T> WithLogging<T>(this IEnumerable<T>
source,
string name)
{
foreach (T element in source)
{
Console.WriteLine("{0}: {1}", name, element);
yield return element;
}
}
}