A NullReferenceException
is not thrown when you pass a null parameter, it is thrown when you try and access a member property/method/field on a null reference. In your case it means that this.trainingMethod
is null
.
If trainNetwork
had validation code to verify that the incoming parameters were not null, you would most likely get an ArgumentNullException
with the name of the parameter that was null indicated.
If trainNetwork
tried to reference an instance member on a null value that you passed in, the stack trace would originate from that method, not from train
.