Today I learned how to implement a method that accepts a variable number of arguments of the same type.

In C#, we use “params” keyword.

In F#, we use the ParamArray attribute.

open System

type MyClass() =

    member this.SomeMethod([<ParamArray>](args:(string*string) array)) = ()
    

let someInstance = MyClass()

someInstance.SomeMethod( ("Table1","Column1"),
                         ("Table2","Column2"),
                         ("Table3","Column3"),
                         ("Table4","Column4") )

The example above demonstrates how an variable number of typed arguments can be passed to a method. The End.

Advertisements