I recently created a generic Matrix<T> class that acts as a wrapper around a List<List<T>> collection. As far as I can tell, this class is working perfectly. I am running into a slight problem though regarding the default values of the T's.
I create an instance of Matrix<int>(3, 3), which creates a 3x3 matrix of ints, all defaulted to 0 using default(T). I know that value types (which include primitives) default to a 0 equivalent, and reference types default to null. I was wondering if it was possible to change this default value so that if a value type is passed into the Matrix, it would be populated with 5's for example, instead of 0's.
I tried creating my own struct (value type), but due to not being able to use parameterless constructors inside structs, I cannot find a way to change the default value from 0.
I suspect changing the default value is not possible, and I will have to loop through the Matrix cell by cell after it has been instantiated, but I wanted to ask on here just in case before I do that.