Skip to content
Loading
asp.net core build a matrix 5x5 and apply style
 
 
  • Marius Vasile
    I think I can do the calculation with 
     
    1. int[] Consequence = { 1, 2, 3, 4, 5 };  
    2.             int[] Likelihood = { 1, 2, 3, 4, 5 };  
    3.   
    4.             for (int i = 1; i < Consequence.Length; i++)  
    5.             {  
    6.                 for(int j =1; j < Likelihood.Length; j++)  
    7.                 {  
    8.                     int num1 = Consequence[i];  
    9.                     int num2 = Likelihood[j];  
    10.                     Result = num1 * num2;  
    11.                 }  
    12.                   
    13.             }  
     but how do I put it in View
  • Marius Vasile
    I will try it, I have it on the paper but hard to put in code
  • Sachin Singh
    for a*b use cross join as
    1. var result = from e in FirstArray  
    2.              from d in secondArray     
    3.              select new { e, d };  
    4.    
    BTW, matrix is created like this
    1. var numbers = new int[5,5] { { 1, 2, 3, 4, 5 },   
    2. { 2, 3, 4, 5, 6 }, { 1, 2, 3, 4, 5 }, { 2, 3, 4, 5, 6 }, { 1, 2, 3, 4, 5 }};  
    3.   
    4. private void Matrix()  
    5. {  
    6.     for (int i = 0; i < 5; i++)  
    7.     {  
    8.         for (int j = 0; j < 5; j++)  
    9.         {  
    10.             list_Matrix.Add(numbers[i,j].To String());  
    11.         }  
    12.     }  
    13. }