Collection initializers and Add method with more than one parameter

I didn’t know this about C# until today. This code compiles:

 using System;
using System.Collections.Generic;
  
class List : List<Tuple<string, int, bool>>
{
    public void Add(string s, int i, bool b)
    {
        Add(Tuple.Create(s, i, b));
    }
  
    static void Main(string[] args)
    {
        var list = new List
        {
             { "zero", 0, true },            { "one", 1, false } 

        };
 
        foreach (var item in list)
        {
            Console.WriteLine(item.ToString());
        }
    }
}

and outputs:

(zero, 0, True)

(one, 1, False)

It turns out, the way collection initializers work they pattern match to expect the Add method on the list object, and it can have more than one or two parameters. This is extremely handy for writing declarative, data-driven unit-tests where you only specify the data for your scenario and the imperative control-flow of the test is abstracted away into a helper method. This allows you to shape the relevant data in a way convenient to be able to clearly read the test scenario.

P.S. For a second, I admit to having a thought “I bet even Jon Skeet didn’t know about this one”, but then of course I opened C# in Depth 2nd Edition, page 216 and was once again in awe of Jon’s superpowers. Sorry for ever having the slightest of doubt, Jon, won’t happen again!