楼上已经说了理论,那我写个实例吧
- private void button1_Click(object sender, EventArgs e)
- {
- shili("a", "b", "c", "abc", "睡觉");
- shili(new string[] { "a", "b", "c", "abc", "睡觉" });
- }
- private void shili(params string[] s)
- {
- if (s.Length != 0)
- {
- foreach (string t in s)
- {
- Console.WriteLine(t);
- }
- }
- }
复制代码 |