I am writing a text template and have the following line of code:
Tuple<string, int, bool>[] tupleArray = new[]
{
new Tuple<string, int, bool>("apple", 4, true),
new Tuple<string, int, bool>("grape", 1, false)
};
I would like to convert this to an array of anonymous types :
var anonArray = new[]
{
new {Name = "apple", Diam = 4, Tasty = true},
new {Name = "grape", Diam = 1, Tasty = false}
};
The text template, however, although it is the only continuous function, does not allow the use of implicitly typed local variables.
Is there an easy way to get around this limitation and use anonymous types in a text template?
source
share