TIL (meaning, Tonight I Learned) that you can declare non-optional parameters after optional ones in C#.
Just create an indexer with optional parameters:
int this[int a, string b = "b"] { get; set; }
The IL for the set method is this:
instance void set_Item (
int32 a,
[opt] string b,
int32 'value'
) cil managed
{
.param [2] = "b"
}
Note that the "value" is after b.
@jasonbock Or you can use the attributes instead of the C# syntax
@meziantou Great, thanks for another edge case.