Skip to content

Commit 2261a2a

Browse files
Add regions to 11.1
1 parent 7079aa3 commit 2261a2a

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter11.Listing11_01
22
{
33
using System;
4-
54
#region INCLUDE
65
public sealed class TextNumberParser
76
{
@@ -11,34 +10,31 @@ public static int Parse(string textDigit)
1110
{ "zero", "one", "two", "three", "four",
1211
"five", "six", "seven", "eight", "nine" };
1312

14-
#if !PRECSHARP7
15-
int result = Array.IndexOf(
16-
digitTexts,
17-
// Leveraging C# 2.0’s null-coalescing operator
18-
(textDigit ??
19-
// Leveraging C# 7.0’s throw expression
20-
throw new ArgumentNullException(nameof(textDigit))
21-
).ToLower());
22-
#else
23-
if(textDigit == null) throw new ArgumentNullException(nameof(textDigit))
13+
#region EXCLUDE
14+
//int result = Array.IndexOf(
15+
// digitTexts,
16+
// // Leveraging C# 2.0’s null-coalescing operator
17+
// (textDigit ??
18+
// // Leveraging C# 7.0’s throw expression
19+
// throw new ArgumentNullException(nameof(textDigit))
20+
// ).ToLower());
21+
#endregion EXCLUDE
22+
23+
if (textDigit == null) throw new ArgumentNullException(nameof(textDigit))
2424
int result = Array.IndexOf(
2525
digitTexts, textDigit?.ToLower());
26-
#endif
2726

2827
if (result < 0)
2928
{
30-
#if !PRECSHARP6
31-
// Leveraging C# 6.0's nameof operator
32-
throw new ArgumentException(
33-
"The argument did not represent a digit", nameof(textDigit));
34-
#else
29+
#region HIGHLIGHT
3530
throw new ArgumentException(
3631
"The argument did not represent a digit",
3732
"textDigit");
38-
#endif
33+
#endregion HIGHLIGHT
3934
}
4035

4136
return result;
4237
}
4338
}
39+
#endregion INCLUDE
4440
}

0 commit comments

Comments
 (0)