Params Modifier
- The params modifier is used when a method takes a variable number of inputs. It is similar to the spread/ ellipsis operator in other programming languages
- The type of the value passed must be a single dimensional Array (Else will result in compile time error)
- No parameter can be use after using params in method declaration and it can only be used once in a method declaration
Ref Modifier
The ref modifier is used to pass a value type parameter to an method as a reference type parameter (This should be avoided as much as possible its seen as a code smell)
Out Modifier
- It is similar to the ref modifier it passes a value type parameter as a reference type parameter
- The one difference is that the parameter that is passed to the method does not need to be initialized
- When using out the parameters can be accessed outside without using the return keyword (similar to reference type)
- This should also be avoided as much as possible has its seen as a code smell (There are some inbuilt methods that make use of the out modifier)
Methods - C# Programming Guide | Microsoft Docs
params keyword for parameter arrays - C# reference | Microsoft Docs