Swicthed value to nameof(value)
MODIFY
src/Chapter06/Listing06.20.ProvidingPropertyValidation.cs
src/Chapter06/Listing06.20.ProvidingPropertyValidation.cs
@@ -61,6 +61,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_20
if(value == null)
{
// Report error
+ // In C# 6.0 replace "value" with nameof(value)
throw new ArgumentNullException("value");
}
else
@@ -71,7 +72,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_20
if(value == "")
{
throw new ArgumentException(
- "FirstName cannot be blank.", "value");
+ // Use "value" rather than nameof(value)
+ // prior to C# 6.0.
+ "FirstName cannot be blank.", nameof(value));
}
else
{

MODIFY
src/Chapter06/Listing06.22.DefiningCalculatedProperties.cs
src/Chapter06/Listing06.22.DefiningCalculatedProperties.cs
@@ -67,7 +67,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_22
// name was not assigned
throw new System.ArgumentException(
$"Assigned value '{ value }' is invalid",
- "value");
+ // Use "value" rather than nameof(value)
+ // prior to C# 6.0.
+ nameof(value));
}
}
}

MODIFY
src/Chapter06/Listing06.53.DefiningAPartialMethodToAccessItsImplementation.cs
src/Chapter06/Listing06.53.DefiningAPartialMethodToAccessItsImplementation.cs
@@ -58,15 +58,17 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_53
{
if(value == null)
{
- // In C# 6.0 replace "value" with nameof(value)
- throw new ArgumentNullException("value");
+ // Use "value" rather than nameof(value)
+ // prior to C# 6.0.
+ throw new ArgumentNullException(nameof(value));
}
if(value.Trim().Length == 0)
{
- // In C# 6.0 replace "value" with nameof(value)
throw new ArgumentException(
"LastName cannot be empty.",
- "value");
+ // Use "value" rather than nameof(value)
+ // prior to C# 6.0.
+ nameof(value));
}
}
@@ -74,15 +76,17 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter06.Listing06_53
{
if(value == null)
{
- // In C# 6.0 replace "value" with nameof(value)
- throw new ArgumentNullException("value");
+ // Use "value" rather than nameof(value)
+ // prior to C# 6.0.
+ throw new ArgumentNullException(nameof(value));
}
if (value.Trim().Length == 0)
{
- // In C# 6.0 replace "value" with nameof(value)
throw new ArgumentException(
"FirstName cannot be empty.",
- "value");
+ // Use "value" rather than nameof(value)
+ // prior to C# 6.0.
+ nameof(value));
}
}

Swicthed value to nameof(value)