src/Keeg.Crypto/Common/Utils.cs
/// <summary>
/// Generic function to create a shallow copy of a jagged array.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="source">The source array to copy from.</param>
/// <returns>A shallow copy of the jagged array provided.</returns>
Generic function to create a shallow copy of a jagged array.
Generic function to create a shallow copy of a jagged array .
internal static T[][] CopyArray<T>(T[][] source)
        {
            var length = source?.Length ?? throw new ArgumentNullException(nameof(source));
            var destination = new T[length][];
            for (var i = 0; i < length; ++i)
            {
                var innerArray = source[i];
                var innerLength = innerArray.Length;
                var newArray = new T[innerLength];
                Array.Copy(innerArray, newArray, innerLength);
                destination[i] = newArray;
            }
            return destination;
        }
internal static T [ ] [ ] CopyArray < T > ( T [ ] [ ] source ) { var length = source ? . Length ?? throw new ArgumentNullException ( nameof ( source ) ) ; var destination = new T [ length ] [ ] ; for ( var i = 0 ; i < length ; ++ i ) { var innerArray = source [ i ] ; var innerLength = innerArray . Length ; var newArray = new T [ innerLength ] ; Array . Copy ( innerArray , newArray , innerLength ) ; destination [ i ] = newArray ; } return destination ; }
Generic function to create a shallow copy of a jagged array.
Generic function to create a shallow copy of a jagged array .
A shallow copy of the jagged array provided.
A shallow copy of the jagged array provided .
source
T[][]
The source array to copy from.
The source array to copy from .
typeparam
None