nameof
operator instead of explicitly spelling out the parameter CS-R1059ArgumentException
is generally thrown when an unexpected argument is passed to a method. Explicitly spelling out the parameter whilst throwing such exceptions is not a good idea as parameter names are subject to change during code refactoring and may produce misleading information in the stracktrace. It is therefore recommended that you use the nameof
operator to spell out such parameters instead.
throw new ArgumentException("age");
throw new ArgumentException(nameof(age));