wpf 如何在C#中创建bool类型的二维数组

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16810701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 08:52:54  来源:igfitidea点击:

how to create two dimensional Array of type bool in C#

c#wpfwpf-controlswpfdatagrid

提问by Indhi

I have a matrixkind datagridin my WPF application and I would like to create a two dimensional Arrayto access the row and column of the datagrid. how to access the datagridcells using 2-dimensional arrays of type bool, since my result will be of type Boolean.

我的WPF 应用程序中有一种matrix类型datagrid,我想创建一个二维Array来访问datagrid. 如何使用布尔类型的二维数组访问数据网格单元,因为我的结果将是布尔类型。

for each [i][j] of this 10 x 10 rows, column array, I have to query

对于这 10 x 10 行列数组的每个 [i][j],我必须查询

for example

例如

[0][0] = result of one query

[0][1] = result of another query

EDIT

编辑

What I have tried

我试过的

bool[,] cell = new bool[10, 10];

        for (int i = 0; i < 10; i++)
        {
            for(int j= 0; j<10 ;j++)
            {
            cell[i,j] = (); // what to write here 
            }
        }

回答by Kaveh Shahbazian

You can define 2D arrays in C#:

您可以在 C# 中定义二维数组:

var array2D = new int[13, 100];
array2D[7, 11] = 48;