enter image description here 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: enter image description here

Closed due to the fact that it is off-topic by the participants andreycha , ermak0ff , aleksandr barakin , Visman , LbISS Sep 28 '15 at 11:32 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - andreycha, ermak0ff, aleksandr barakin, Visman, LbISS
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    You have written: public abstract partial Matrix <T, U>. Where is the second part of the class? - Pavel Mayorov
  • Yes, give the complete exception of the spectrum. Often, the error of the stack overflow is not the lowest element to blame ... - Pavel Mayorov
  • var m = new Matrix <double, RealField> (new Pair <ulong> (3, 4)); - Anton Tolstov
  • The fact is that while this is the only part of the class: the others have not been developed yet. If you debug, you can see that other code is not called - Anton Tolstov
  • Let's stack, without him, this is a fortune telling. - VladD

0