ch. 17 code changes
MODIFY
src/Chapter17/Chapter17.csproj
src/Chapter17/Chapter17.csproj
<Compile Remove="Listing17.19.CSharpEquivalentOfCompilerGeneratedCodeForIterators.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="Listing17.11.SpecifyingAReturnAttribute.Description.cs" />
<None Include="Listing17.19.CSharpEquivalentOfCompilerGeneratedCodeForIterators.cs" />
<Compile Include="..\Shared\Program.cs">
<Link>Program.cs</Link>

MODIFY
src/Chapter17/Listing17.08.ImplementingIEqualityComparer.cs
src/Chapter17/Listing17.08.ImplementingIEqualityComparer.cs
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter17.Listing17_08
{
#region INCLUDE
- using System;
using System.Collections.Generic;
public class ContactEquality : IEqualityComparer<Contact>
{
public bool Equals(Contact? x, Contact? y)
{
- if(Object.ReferenceEquals(x, y))
+ if(object.ReferenceEquals(x, y))
return true;
if(x == null || y == null)
return false;
@@ -28,7 +27,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter17.Listing17_08
}
#endregion INCLUDE
- class Contact
+ public class Contact
{
public string FirstName { get; private set; }
public string LastName { get; private set; }

MODIFY
src/Chapter17/Listing17.20.UsingYieldReturnInAMethodThatReturnsIEnumberable.cs
src/Chapter17/Listing17.20.UsingYieldReturnInAMethodThatReturnsIEnumberable.cs
@@ -4,17 +4,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter17.Listing17_20
using Listing17_10;
using System.Collections.Generic;
- public class Program
- {
- public static void Main()
- {
- var game = new Pair<string>("Redskins", "Eagles");
- foreach(string name in game.GetReverseEnumerator())
- {
- Console.WriteLine(name);
- }
- }
- }
+
#region INCLUDE
public struct Pair<T> : IPair<T>, IEnumerable<T>
{
@@ -55,22 +45,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter17.Listing17_20
yield return Second;
yield return First;
}
- #endregion INCLUDE
- //Listing 16.20 Using yield return in a Method That Returns IEnumerable<T>
-
- //Listing 16.18 Escaping Iteration via yield break
- public System.Collections.Generic.IEnumerable<T> GetNotNullEnumerator()
- {
- if((First == null) || (Second == null))
- {
- yield break;
- }
- yield return Second;
- yield return First;
- }
- //Listing 16.18 Escaping Iteration via yield break
-
-
+ #region EXCLUDE
#region IEnumerable<T>
public IEnumerator<T> GetEnumerator()
{
@@ -87,4 +62,17 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter17.Listing17_20
}
#endregion
}
+ public class Program
+ {
+ #endregion EXCLUDE
+ public static void Main()
+ {
+ var game = new Pair<string>("Redskins", "Eagles");
+ foreach (string name in game.GetReverseEnumerator())
+ {
+ Console.WriteLine(name);
+ }
+ }
+ #endregion INCLUDE
+ }
}

ch. 17 code changes