Horje
jagged array to 2d array c# Code Example
jagged array to 2d array c#
static T[,] To2D<T>(T[][] source)
{
    try
    {
        int FirstDim = source.Length;
        int SecondDim = source.GroupBy(row => row.Length).Single().Key; // throws InvalidOperationException if source is not rectangular

        var result = new T[FirstDim, SecondDim];
        for (int i = 0; i < FirstDim; ++i)
            for (int j = 0; j < SecondDim; ++j)
                result[i, j] = source[i][j];

        return result;
    }
    catch (InvalidOperationException)
    {
        throw new InvalidOperationException("The given jagged array is not rectangular.");
    } 
}




Csharp

Related
styles does not exisit in current context Code Example styles does not exisit in current context Code Example
npm install --save vue-route@n Code Example npm install --save vue-route@n Code Example
the name scripts does not exist in the current context mvc 5 Code Example the name scripts does not exist in the current context mvc 5 Code Example
tachyons Code Example tachyons Code Example
import tachyons in react Code Example import tachyons in react Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11