View difference between Paste ID: 0kj5QtfD and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
1 | + | static void Main(string[] args) |
2 | { | |
3 | IEnumerable<string> errors = GetErrors(); | |
4 | foreach (string error in errors) | |
5 | { | |
6 | Console.WriteLine(error); | |
7 | } | |
8 | Console.ReadKey(); | |
9 | } | |
10 | ||
11 | private static IEnumerable<string> GetErrors() | |
12 | { | |
13 | return GetMoreErrors().Concat(GetOtherErrors()) | |
14 | .Concat(GetValidationErrors()) | |
15 | .Concat(AnyMoreErrors()) | |
16 | .Concat(ICantBelieveHowManyErrorsYouHave()); | |
17 | } | |
18 | ||
19 | private static IEnumerable<string> GetMoreErrors() | |
20 | { | |
21 | Console.WriteLine("Within GetMoreErrors"); | |
22 | yield return "GetMoreErrors"; | |
23 | } | |
24 | ||
25 | private static IEnumerable<string> GetOtherErrors() | |
26 | { | |
27 | Console.WriteLine("Within Method GetOtherErrors"); | |
28 | yield return "OtherErrors"; | |
29 | } | |
30 | ||
31 | private static IEnumerable<string> GetValidationErrors() | |
32 | { | |
33 | Console.WriteLine("Within GetValidationErrors"); | |
34 | yield return "GetValidationErrors"; | |
35 | } | |
36 | ||
37 | private static IEnumerable<string> AnyMoreErrors() | |
38 | { | |
39 | Console.WriteLine("Within AnyMoreErrors"); | |
40 | yield return "AnymoreErrors"; | |
41 | } | |
42 | ||
43 | private static IEnumerable<string> ICantBelieveHowManyErrorsYouHave() | |
44 | { | |
45 | Console.WriteLine("Within ICantBelieveHowManyErrorsYouHave"); | |
46 | yield return "ICantBelieveHowManyErrorsYouHave"; | |
47 | } | |
48 | ||
49 | Output: | |
50 | Within GetMoreErrors | |
51 | GetMoreErrors | |
52 | Within Method GetOtherErrors | |
53 | OtherErrors | |
54 | Within GetValidationErrors | |
55 | GetValidationErrors | |
56 | Within AnyMoreErrors | |
57 | AnymoreErrors | |
58 | Within ICantBelieveHowManyErrorsYouHave | |
59 | ICantBelieveHowManyErrorsYouHave |