本文介绍了如何声明一个二维字符串数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string[][] Tablero = new string[3][3];

我需要一个 3x3 的阵列排列来保存信息.我如何在 C# 中声明它?

I need to have a 3x3 array arrangement to save information to. How do I declare this in C#?

推荐答案

string[,] Tablero = new string[3,3];

您也可以在同一行中使用数组初始值设定项语法对其进行实例化,如下所示:

You can also instantiate it in the same line with array initializer syntax as follows:

string[,] Tablero = new string[3, 3] {{"a","b","c"},
                                      {"d","e","f"},
                                      {"g","h","i"} };

这篇关于如何声明一个二维字符串数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 18:05