How to send comma separated list of arguments to a method with object array as parameter in C#

1 Answer

0 votes
using System;

public class Program
{
    public static void WithParams(params object[] arr) {
        for (int i = 0; i < arr.Length; i++) {
            Console.Write(arr[i] + " ");
        }
        Console.WriteLine();
    }


    static void Main() {
        WithParams(1, 3, 'a', "c#");
    }
}



/*
run

1 3 a c# 

*/

 



answered Nov 27, 2020 by avibootz

Related questions

2 answers 213 views
1 answer 197 views
1 answer 187 views
1 answer 168 views
...