tempus
Member
- Joined
- Oct 8, 2013
- Messages
- 11
- Programming Experience
- 10+
Below is a simple code snippet based on existing code. For the life of me I just cant figure out how to pass that 'item' into the generic method. The error is on line 12 and is telling me the type argument cannot be inferred from the usage. I will admit, I did convert this code from some VB.NET code I have been using and the inference in VB.NET can be much looser so I'm sure that's where this all started. Any suggestions would be greatly appreciated.
class Program { static void Main(string[] args) { var foo = new ArrayList(); var b = new bar() { foobar = "Test" }; foo.Add(b); foreach (var item in foo) { tester(item); } } static void tester<T>(List<T> items) { //do something; } } public class bar { public string foobar { get; set; } }