The following code gives me this error:
Cannot convert from \'System.Collections.Generic.List\' to \'System.Collections.Generic.List\'.
Instead of passing List which does not work for the reasons above, could you not simply pass just an object reference then get the list type afterwards, kinda like...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1 {
class Customer {
public int id;
public string name;
}
class Monkey {
public void AcceptsObject(object list) {
if (list is List) {
List customerlist = list as List;
foreach (Customer c in customerlist) {
Console.WriteLine(c.name);
}
}
}
}
class Program {
static void Main(string[] args) {
Monkey monkey = new Monkey();
List customers = new List { new Customer() { id = 1, name = "Fred" } };
monkey.AcceptsObject(customers);
Console.ReadLine();
}
}
}