我想将字符L乘以c#中的单位矩阵

时间:2010-05-31 08:28:13

标签: c#

 for (int row = 0; row < SS; row++)
        {
            for (int col = 0; col < SS; col++)
            {
                    identity[row, col] = (row == col) ? 1 : 0;

                Response.Write(identity[row, col] + " ");
            }
            Response.Write("<br/>"); 
        }

现在我的输出是1 0 0 0 1 0 0 0 1

我希望输出为L 0 0 0 L 0 0 0 L

2 个答案:

答案 0 :(得分:0)

identity [row,col] =(row == col)? “L”:“0”;

答案 1 :(得分:0)

将您的数组声明为字符串(或字符串)并尝试此操作:

identity[row, col] = (row == col) ? "L" : "0";