C# | Detailed Explained solution | with workflow
Steps involved here:\n1. We will create a prefixSum Array - (Loops1 in diagram)\n2. We use LoopA to leave behind the checked columns. Each iteration the matrix 
Steps involved here:\n1. We will create a prefixSum Array - (Loops1 in diagram)\n2. We use LoopA to leave behind the checked columns. Each iteration the matrix which we will check will decrease by 1 column.\nthis line will take care of that - ![image](https://assets.leetcode.com/users/images/07475203-3d6c-43b7-b4da-ffbdeda1a584_1658163863.0686345.png)\n\n![image](https://assets.leetcode.com/users/images/53c6a404-38e4-40ba-b7bd-b30868469365_1658162903.8814688.png)\n\n3. LoopB to check all the posisble sums in the active sub matrix\n![image](https://assets.leetcode.com/users/images/b6edd7c7-c86f-4fd1-a1c2-56e56ce550f8_1658163012.0017807.png)\n\n\n4. Loop C to iterate over each row and find the number of sums we can get.\n![image](https://assets.leetcode.com/users/images/9081460c-72b8-4f73-84b4-b2241ed3403a_1658163139.1419709.png)\n\n\n![image](https://assets.leetcode.com/users/images/9c52cb1c-da8b-4380-b22e-bdcd4bbc77c3_1658162353.179597.png)\n\n```\npublic class Solution {\n    public int NumSubmatrixSumTarget(int[][] matrix, int target) {\n        for(int i=0; i< matrix.Length; i++){\n            for(int j=1; j< matrix[0].Length; j++){\n                matrix[i][j] += matrix[i][j-1]; \n            }\n        }\n        int counter = 0;\n        //this loop will remove previous column by 1 so that remaining columns will be checked\n        for(int col1=0; col1 < matrix[0].Length; col1++){\n            //this loop will be used to check the column starting from above and ending till end\n            for(int col2=col1; col2< matrix[0].Length; col2++){\n                Dictionary<int,int> records = new Dictionary<int,int>();\n                records[0] = 1;\n                int sum = 0;\n                for(int row=0; row < matrix.Length; row++){\n                    sum += matrix[row][col2] - (col1 > 0 ? matrix[row][col1-1] : 0);\n                    int prefixSum = sum - target;\n                    if(records.ContainsKey(prefixSum)){\n                        counter += records[prefixSum];\n                    }\n                    if(records.ContainsKey(sum))\n                        records[sum] += 1;\n                    else\n                    records[sum] = 1;\n                    \n                }\n            }\n        }\n        return counter;\n    }\n}\n```
['C#']