C# Feature - Params collections
Overview
Section titled βOverviewβParams collections extend params so APIs can accept more collection forms while keeping a natural call-site syntax.
Introduced In
Section titled βIntroduced InβC# 13.0 (2024)
public static void Log(params string[] items) { }public static void Log(params ReadOnlySpan<string> items) { }Annotated Example
Section titled βAnnotated ExampleβLog("info", "payments", "approved");Gotchas & Best Practices
Section titled βGotchas & Best Practicesβ- Use params collections for API design when spans or custom collection builders are a better fit than arrays.
- Keep overloads unambiguous when mixing
paramsand non-paramssignatures.
Related Features
Section titled βRelated FeaturesβVersion Notes
Section titled βVersion Notesβ- C# 13 broadened
paramssupport beyond arrays.