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

Printing Array elements with Comma delimiters的更多相关文章

  1. [LeetCode] Minimum Moves to Equal Array Elements II 最少移动次数使数组元素相等之二

    Given a non-empty integer array, find the minimum number of moves required to make all array element ...

  2. [LeetCode] Minimum Moves to Equal Array Elements 最少移动次数使数组元素相等

    Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...

  3. LeetCode Minimum Moves to Equal Array Elements II

    原题链接在这里:https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/ 题目: Given a non-empt ...

  4. LeetCode Minimum Moves to Equal Array Elements

    原题链接在这里:https://leetcode.com/problems/minimum-moves-to-equal-array-elements/ 题目: Given a non-empty i ...

  5. LeetCode 453 Minimum Moves to Equal Array Elements

    Problem: Given a non-empty integer array of size n, find the minimum number of moves required to mak ...

  6. Leetcode-462 Minimum Moves to Equal Array Elements II

    #462.   Minimum Moves to Equal Array Elements II Given a non-empty integer array, find the minimum n ...

  7. LeetCode 453. Minimum Moves to Equal Array Elements C#

    Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...

  8. 【LeetCode】462. Minimum Moves to Equal Array Elements II

    Given a non-empty integer array, find the minimum number of moves required to make all array element ...

  9. 13. leetcode 453. Minimum Moves to Equal Array Elements

    Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...

随机推荐

  1. 全志A20芯片用于启动的SD卡的布局

    起始 大小 内容 0 8KB 存放分区表等 8 24KB SPL loader 32 512KB u-boot 544 128KB environment 672 352KB 保留 1024 - 用于 ...

  2. linux中使用软链接时出现 too many levels of symbolic links

    刚开始使用的源文件的路径是相对路径,所以导致标题中的这种错误. 只要用绝对路径表示源文件就好了.如果用相对路径的话,实际相对的是目标文件所在的路径,而在创建链接文件时用的路径是相对于当前的路径.

  3. php防止表单重复提交

    解决方案一:引入cookie机制来解决 提交页面代码如下a.php代码如下: <form id="form1" name="form1" method=& ...

  4. dataTabel转成dataview插入列后排序

    if (!string.IsNullOrEmpty(strQuyu) && !string.IsNullOrEmpty(strZuhao)) { string[] param = { ...

  5. msyql数据库位置

    MySQL默认的数据文件存储目录为/var/lib/mysql.假如要把目录移到/home/data下需要进行下面几步: 1.home目录下建立data目录 cd /home mkdir data 2 ...

  6. mysql单表查询&&多表查询(职员表14+9)

    dept(deptno,dname,loc) emp(empno,ename,job,mgr,hiredate,sal,COMM,deptno) salgrade(grade,losal,hisal) ...

  7. 怎样使用AutoLayOut为UIScrollView添加约束

    1.在ViewController中拖入1个UIScrollView,并为其添加约束 约束为上下左右四边与superview对齐 2.在scrollview中,拖入1个UIView,为了便于区分将其设 ...

  8. oracle 数据泵 详解

    导出数据 1)按用户导 expdp scott/tiger@orcl schemas=scott dumpfile=expdp.dmp DIRECTORY=dir logfile=expdp.log ...

  9. Caused by: javax.xml.bind.JAXBException: standardPremiumUpdateMessageDTO is not a valid property on

    Caused by: javax.xml.bind.JAXBException:  standardPremiumUpdateMessageDTO is not a valid property on ...

  10. sql server 快捷键

    书签:清除所有书签. CTRL-SHIFT-F2 书签:插入或删除书签(切换). CTRL+F2 书签:移动到下一个书签. F2 功能键 书签:移动到上一个书签. SHIFT+F2 取消查询. ALT ...