Can anyone please tell me why method parameter IEnumerable returns null even though it is assigned at the callee method. We all know interface is an reference type.
Dont consider the logic. I just replaced my business logic to suit the scenario
static void Main()
{
IEnumerable<int> gEnumerable = null;
Foo(gEnumerable); //here param gEnumerable always returns null even if i assign value at my Foo(), why is it so???
}
static IEnumerable<int> Bar(List<int> lst)
{
return lst.Select(k => k);
}
private static void Foo(IEnumerable<int> response)
{
response = Bar(new List<int> { 1, 2, 3, 4, 5, 6 });
}
Kindly explain me regarding this