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, though it appears to be a single contiguous function, does not allow the use of implicitly typed local variables.
Is there a simple way to bypass this limitation and use anonymous types within a text template?