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)
Before
Section titled “Before”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.