Sample code :
using System.Collections.Generic;
using FileHelpers;
....
private void Save<T>(string destFilename, IEnumerable<T> data) where T : class
{
var engine = new FileHelperEngine((typeof(T)));
engine.HeaderText = engine.GetFileHeader();
engine.WriteFile(destFilename, data); // XX
}
At line XX, the 2nd parameter to engine.WriteFile is expecting an IEnumerable<object>. This code works ok.
My question is, why is the "where T : class" constraint required on the method ? If I remove it, I get the compile time error :
Argument 2: cannot convert from
'System.Collections.Generic.IEnumerable<T>' to
'System.Collections.Generic.IEnumerable<object>'
I would have thought that everything was an "object", and so that the constraint was not necessary ?