basically I\'m building a very generic T4 template and one of the things I need it to do is say print variable.ToString()
. However, I want it to evaluate lists and
You have already accepted an answer however,since generic IEnumerable
implements the non generic IEnumerable
you can just cast to that.
// Does write handle null? Might need some sanity aswell.
var enumerable = variable as System.Collections.IEnumerable;
if (enumerable != null)
foreach(var item in enumerable)
Write(item);
else
Write(item);