I had a suspicion that you had a
DnaSequence
that didn't initialize the
mySites
field.
I found it when I looked at the linked code file...
Most of your constructors
do not initialize the
mySites
field!!!
I'd suggest changing them to this:
public DnaSequence()
: this(0, 0, null)
{
}
public DnaSequence (int N)
: this(N, 0, null)
{
}
public DnaSequence(int N,int score)
: this(N, score, null)
{
}
public DnaSequence (int N, int score, string name)
{
if (N < 0)
{
throw new ArgumentException ("DnaSequence(): N (= " + N + ") < 0, illegal)");
}
this.mySites = new byte[N + PAD];
this.myLength = N;
this.myScore = score;
this.myName = name;
}
This will ensure that all of the constructor forms will initialize
mySites
and additionally it ensures they all do the validity check on
N
.
Also, another way to accomplish the same thing is to use optional arguments:
public DnaSequence (int N = 0, int score = 0, string name = null)
{
if (N < 0)
{
throw new ArgumentException ("DnaSequence(): N (= " + N + ") < 0, illegal)");
}
this.mySites = new byte[N + PAD];
this.myLength = N;
this.myScore = score;
this.myName = name;
}
in which case the other 3 forms of constructor should be removed entirely!