How exactly keyword 'params' work?
问题 The following code sample prints: T T[] T[] While first two lines are as expected, why compiler selected param array for a regular array? public class A { public void Print<T>(T t) { Console.WriteLine("T"); } public void Print<T>(params T[] t) { Console.WriteLine("T[]"); } } class Program { static void Main(string[] args) { A a = new A(); a.Print("string"); a.Print("string","string"); a.Print(new string[] {"a","b"}); } } 回答1: Under the hood a.Print("string","string"); is just syntactic sugar