string[][]和string[,]

http://www.codewars.com/kata/56f3a1e899b386da78000732/train/csharp

Write a function partlist that gives all the ways to divide a list (an array) of at least two elements in two non-empty parts.

  • Each two non empty parts will be in a pair (or an array for languages without tuples)
  • Each part will be in a string
  • Elements of a pair must be in the same order as in the original array.

Example:

a = ["az", "toto", "picaro", "zone", "kiwi"]

[[az, toto picaro zone kiwi], [az toto, picaro zone kiwi], [az toto picaro, zone kiwi], [az toto picaro zone, kiwi]]

string[][]  一维数组,数组元素是string[]

string[,]    二维数组,数组元素是string

using System.Linq;

public class PartList
{
public static string[][] Partlist(string[] input)
{
var output = new string[input.Length - ][];
for (int i = ; i < input.Length - ; i++)
{
var temp = input.ToArray();
temp[i] = $"{input[i]},";
output[i] = new[] { string.Join(" ", temp) };
}
return output;
}
}

int[][]和int[,]

https://www.codewars.com/kata/adding-values-of-arrays-in-a-shifted-way/train/csharp

int[][]  一维数组,数组元素是int[];这个的行是固定的,但是没有固定的列,是锯齿的

int[,]    二维数组,数组元素是int;二维数组是一个矩阵,行和列是固定的

http://stackoverflow.com/questions/20050571/c-sharp-indexoutofrangeexception-when-calling-array-getlength1-for-a-2d-array

It's not a 2D array. TileData[][] is a jagged array, TileData[,] is a 2D array then, in your case, GetLength(1) will always fail because tile has only one dimension.

string[][]和string[,] 以及 int[][]和int[,]的更多相关文章

  1. C#,int转成string,string转成int

    转载:http://www.cnblogs.com/xshy3412/archive/2007/08/29/874362.html 1,int转成string用toString 或者Convert.t ...

  2. [C#]List<int>转string[],string[]转为string

    // List<int>转string[] public string[] ListInt2StringArray(List<int> input) { return Arra ...

  3. c# List<int> 转 string 以及 string [] 转 List<int>

    List<int> 转 string : list<int>: 1,2,3,4,5,6,7  转换成字符串:“1,2,3,4,5,6,7” List<int> li ...

  4. 根据群ID和用户Id查询 + string QueryQunByUserIdAndQunId(int userId, int qunId) V1.0

    #region  根据群ID和用户Id查询 + string QueryQunByUserIdAndQunId(int userId, int qunId)  V1.0 /// <summary ...

  5. 将String类型的数字字符转换成int

    java.lang.Integer.parseInt(String) public static int parseInt(String s) throws NumberFormatException ...

  6. c#中关于String、string,Object、object,Int32、int

    在java中,string和String有着明显的区别,后者就是前者的一个封装.在c#中,好像是通用的,大部分情况下,两者互换并不会产生问题.今天特意查了一下资料,了解了一下两者的关系. 简单的讲,S ...

  7. c语言,string库函数itoa实现:将int转换为char*

    原型:char  *itoa(int   value,char   *string)        功能:将整数value转换成字符串存入string,默认为十进制;      说明:返回指向转换后的 ...

  8. C++中int转为char 以及int 转为string和string 转int和空格分隔字符串

    1.对于int 转为char 直接上代码: 正确做法: void toChar(int b) { char u; ]; _itoa( b, buffer, ); //正确解法一 u = buffer[ ...

  9. 用java8重写Arrays.sort(oldWay, new Comparator<String>(){@Override public int compare(String s1, String s2)});

    参考https://www.liaoxuefeng.com/article/001411306573093ce6ebcdd67624db98acedb2a905c8ea4000/ Java 8终于引进 ...

  10. JAVA中int转string及String.valueOf()的使用

    日常java开放中,经常会遇到int和String的互转,一般图省事的做法就是: String length = ""+100; length的生成需要使用两个临时字符串" ...

随机推荐

  1. Android文件操作报open failed: EBUSY (Device or resource busy)

    Android删除文件后重新创建时偶尔出现 open failed: EBUSY (Device or resource busy)错误,该错误是Android系统的一个bug,大概的意思类似于win ...

  2. iOS开发中如何实现同步、异步、GET、POST等请求实操演示!

    1.同步请求可以从因特网请求数据,一旦发送同步请求,程序将停止用户交互,直至服务器返回数据完成,才可以进行下一步操作, 2.异步请求不会阻塞主线程,而会建立一个新的线程来操作,用户发出异步请求后,依然 ...

  3. Lazarus 1.44升级到1.6 UTF8处理发生变化了

    首先这里真的要强调一下,由于Freepascal升级到3.0后,FPC的内部将整个代码处理由AnsiString改为了UTF8编码(RTL with default codepage UTF-8). ...

  4. listcontrol 加combobox实现

    头文件 #pragma once#include "D:\Work\山东项目\StandardizedDrawing\sdUtils\CSGrid.h"#include " ...

  5. .net core 使用 textSharp生成pdf

    引入Nuget包 using iTextSharp.text; using iTextSharp.text.pdf; using System; using System.IO; namespace ...

  6. ngFor 循环带索引

    *ngFor="let item of userList,let i = index"   或者 *ngFor="let item of userList index a ...

  7. es6-let/var/const

    const和var区别 for(let i=0;i<3;i++) { console.log(i); } console.log(i); for(var i=0;i<3;i++) { co ...

  8. react typescript 子组件给父组件传值

    //父组件 import * as React from 'react'import { Input } from 'antd'const Search = Input.Searchimport &q ...

  9. 获取springbean的几种方式

    首先我说一下我遇到的问题,再项目初始化时候,spring容器初始化前要执行的操作中使用到了bean去做一些增删改查操作,这样做是不能自己使用springbean的数据源去操作的,所以需要动态获取spr ...

  10. PHP开发错误锦集(持续更新)

    1.trait 命名问题. 问题:trait 里定义的方法找不到 <?php namespace app\controllers; trait Example { public function ...