Samir Bhogayta
Does C# support variable argument on method?
By Samir Bhogayta in C# on Jun 25 2016
  • Samir Bhogayta
    Jun, 2016 25

    The params keyword can be applied on a method parameter that is an array. When the method is invoked, the elements of the array can be supplied as a comma separated list.So, if the method parameter is an object array, void paramsExample(object arg1, object arg2, params object[] argsRest) { foreach (object arg in argsRest) { /* .... */ } } then the method can be invoked with any number of arguments of any type.paramsExample(1, 0.0f, "a string", 0.0m, new UserDefinedType());

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS