Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2010  |  syntax: None  |  size: 1.83 KB  |  hits: 99  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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