Getting an error when throwing a custom exception from a property

65 Views Asked by At

Within a NeuralNetwork class, I've defined the nested class

public class TrainSetCardinalityMismatch : ArgumentOutOfRangeException 

This is to be thrown when a user tries to provide a training set that does not have the same number of elements as the answer set, or vice-versa. So in the setter for the training set, I check to see if the number of elements matches the number of elements in the answer set, and if not, I put

throw new TrainSetCardinalityMismatch();

but it's giving me the error

NeuralNetwork.TrainSetCardinalityMismatch.TrainSetCardinalityMismatch()' is inaccessible due to its protection level

The trainingSet is also a field of the neuralnetwork class (which shouldn't matter since the error is public anyway), and don't think the ArgumentOutOfRangeException is private.

Does anyone have any ideas?

1

There are 1 best solutions below

1
Tara On

ignore this question - I forgot to put an access modifier on the constructor...