> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C# Params Parameter

The `params` keyword is a parameter modifier in C# that enables a method to accept a variable number of arguments of a specified type. When invoked, the compiler automatically aggregates the provided comma-separated values into a single-dimensional array (or, starting in C# 13, other supported collection types) and passes it to the method's execution context.

```csharp theme={"dark"}
// Method signature using the params modifier
public void ProcessData(int requiredArg, params string[] variableArgs)
{
    // variableArgs is treated as a standard string[] within the method body
    int length = variableArgs.Length; 
}
```

## Invocation Mechanics

The compiler handles `params` arguments by dynamically generating the underlying collection at the call site. You can invoke a `params` method in three distinct ways:

```csharp theme={"dark"}
// 1. Passing discrete, comma-separated arguments
ProcessData(100, "Alpha", "Beta", "Gamma");
// Compiler translates to: ProcessData(100, new string[] { "Alpha", "Beta", "Gamma" });

// 2. Passing zero arguments for the params parameter
ProcessData(200);
// Compiler translates to: ProcessData(200, Array.Empty<string>());

// 3. Passing an explicitly instantiated array
string[] existingArray = new string[] { "Delta", "Epsilon" };
ProcessData(300, existingArray);
// Compiler passes the reference to existingArray directly.
```

## Architectural Rules and Constraints

* **Positioning:** The `params` parameter must be the absolute last parameter in the formal parameter list. Signatures like `void Method(params int[] numbers, string text)` will result in a compiler error (CS0231).
* **Multiplicity:** A method signature can declare a maximum of one `params` parameter.
* **Type Requirements:** Prior to C# 13, the `params` type was strictly limited to single-dimensional arrays (e.g., `int[]`, `object[]`). C# 13 introduced **`params` collections**, which builds upon the C# 12 collection expression infrastructure to allow `params` to be applied to types like `Span<T>`, `ReadOnlySpan<T>`, `List<T>`, and `IEnumerable<T>`.
* **Mutually Exclusive Modifiers:** A `params` parameter cannot be combined with `in`, `ref`, or `out` modifiers.
* **No Default Values:** A `params` parameter cannot be assigned a default value in the method signature. Declarations such as `params string[] args = null` will result in a compiler error.
* **Nullability:** If the caller omits the `params` arguments entirely, the compiler injects an empty array (or empty span/collection), guaranteeing the parameter is not `null`. However, a caller can explicitly pass `null` (e.g., `ProcessData(100, null)`), which will result in a `null` reference inside the method.
* **Overload Resolution Precedence:** During method binding, the C# compiler prioritizes exact signature matches over `params` expansions. If `Method(int, string)` and `Method(int, params string[])` both exist, calling `Method(1, "A")` will bind to the exact match, bypassing the array allocation overhead of the `params` overload.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C# Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
