The program crashes when allocating memory for an array ( source = new[3, 4] )
public abstract partial class Matrix<T, U> : ISize<Pair<ulong>>, IEquatable<Matrix<T, U>>, IAddition<Matrix<T, U>>, IMultiply<Matrix<T, U>> where T : IEquatable<T> where U : UniversalAlgebra.Ring<T>, IEquatable<U>, new() { public Matrix(Pair<ulong> size) { this.size = size; ua = new U(); source = new T[3, 4]; //Здесь ошибка } protected Pair<ulong> size; public T[,] source; protected UniversalAlgebra.Ring<T> ua; } And if the constructor is rewritten like this, the memory will be allocated, but when you try to assign one array to another, the stack overflow climbs again:
public Matrix(Pair<ulong> size) { this.size = size; ua = new U(); T[,] tmp = new T[3, 4]; //Всё хорошо source = tmp; //Вылазит ошибка } Tell me, please, what could be the problem?
I removed all the code from Main, and I see this in the debugger: 