C# language feature:
applies to
benefit
how to use
example:
public string sirName; // if this variable name is refactored/renamed the exception below will accurately reflect the renaming/refactored variable name
public string LastName
{
get { return sirName; }
set
{
if (value != sirName)
{
throw new ArgumentException(message: "Name Changed", paramName: nameof(sirName));
// previously the following would cause confusion after a rename/refactoring of sirName.
throw new ArgumentException(message: "Name Changed", paramName: "sirName");
}
}
}