https://www.codewars.com/kata/printing-array-elements-with-comma-delimiters/train/csharp
using System; using System.Collections.Generic; public class Kata { public static string PrintArray(object[] array) { var list = new List<string>(); foreach (var item in array) { var obj = item as object[]; if (obj == null) { list.Add(item.ToString()); } else { string temp = PrintArray(obj); list.Add(temp); } } return string.Join(",", list); } }
关于数组类型的判断,可以使用
a.GetType().IsArray