I follow a convention that I won\'t use any print statements in classes, but I have done a parameter validation in a constructor. Please tell me how to return that validatio
The constructor does return a value - the type being constructed...
A constructor is not supposed to return any other type of value.
When you validate in a constructor, you should throw exceptions if the passed in values are invalid.
public class MyType
{
public MyType(int toValidate)
{
if (toValidate < 0)
{
throw new ArgumentException("toValidate should be positive!");
}
}
}