Switched commented out errors to #if def
MODIFY
src/Chapter08/Listing08.04.CallingExplicitInterfaceMemberImplementations.cs
src/Chapter08/Listing08.04.CallingExplicitInterfaceMemberImplementations.cs
@@ -16,9 +16,11 @@ public class Program
// ...
+ #if COMPILEERROR // EXCLUDE
// ERROR: Unable to call .CellValues directly
// on a contact
- // values = contact.CellValues;
+ values = contact.CellValues;
+ #endif // COMPILEERROR // EXCLUDE
// First cast to IListable
#region HIGHLIGHT

MODIFY
src/Chapter08/Listing08.07.DeclarationWithoutContainingInterface.cs
src/Chapter08/Listing08.07.DeclarationWithoutContainingInterface.cs
@@ -7,16 +7,17 @@ interface IReadableSettingsProvider
interface ISettingsProvider : IReadableSettingsProvider
{
- /*
+
#region INCLUDE
+ #if COMPILEERROR // EXCLUDE
// ERROR: GetSetting() not available on ISettingsProvider
string ISettingsProvider.GetSetting(
string name, string defaultValue)
{
// ...
}
+ #endif // COMPILEERROR // EXCLUDE
#endregion INCLUDE
- */
void SetSetting(string name, string value);
}

MODIFY
src/Chapter08/Table08.01.DefaultImplementedInterfaceMembers.cs
src/Chapter08/Table08.01.DefaultImplementedInterfaceMembers.cs
static void Main()
{
IPerson? person = null;
+ #if COMPILEERROR // EXCLUDE
+ // Error CS0122 'IPerson.GetName()' is
+ // inaccessible due to its protection level
// Non-deriving classes cannot call
// private protected member.
- // person?.GetName();
+ person?.GetName();
+ #endif // COMPILEERROR // EXCLUDE
Console.WriteLine(person);
}
}
public string FirstName { get; }
public string LastName { get; }
+ #if COMPILEERROR // EXCLUDE
// private protected interface members
// are not accessible in derived classes.
-
- // public int PersonTitle =>
- // GetName().ToUpper();
+ public int persontitle =>
+ getname().toupper();
+ #endif // COMPILEERROR // EXCLUDE
}
}

Switched commented out errors to #if def