Nice Pattern

 
event

No, not as in "GOF Design Pattern" but as in "Call Pattern".

I was coding some Web Controls (not my favorite thing) and I needed a way of adding one or more control to an existing one.  ControlCollection.Add just allows one item at a time so I was experimenting while creating a comfortable API. I found out this pattern that allows a lot of flexibility as we can call the method, with one element and various in the shape of a collection (IEnumerable<T>) or in the shape of separated parameters in case the number of items is low.

For example, the method Method in the class:

Can be called like this:

If we wanted to prevent the first call, we could change the params implementation with:

Pretty basic but useful nonetheless...

share class