Advertisement
Guest User

IEnumerable == null /*WTF*/

a guest
Jul 1st, 2010
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace IEnumerableBug
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             try
  11.             {
  12.                 List<System.Int32> lst = new List<System.Int32>();
  13.                 lst.Add(999);
  14.                 IsIEnumerableNull(lst);
  15.                 Console.WriteLine("Post IsIEnumerableNull() call");
  16.             }
  17.             catch (Exception ex)
  18.             {
  19.                 Console.WriteLine("-- Error --");
  20.                 Console.Write(ex.ToString());
  21.             }
  22.             finally
  23.             {
  24.                 Console.WriteLine("\n\nPress any key to exit...");
  25.                 Console.ReadKey();
  26.             }
  27.         }
  28.  
  29.         public static void IsIEnumerableNull(IEnumerable<System.Int32> enumerableObj)
  30.         {
  31.             // validate params
  32.             if (enumerableObj == null) throw new ArgumentNullException("enumerableObj");
  33.  
  34.             try {} catch (Exception /*e*/) { }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement