This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 4th, 2013  |  syntax: None  |  size: 0.76 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public static readonly List<int> MyList;
  2.  
  3. //Initialize MyList in the static constructor
  4. static MyObject() { ... }
  5.        
  6. public static readonly List<int> MyList = GetMyList();
  7.  
  8. //Returns the list
  9. private static List<int> GetMyList() { ... }
  10.        
  11. public static readonly List<int> MyList =
  12.     () =>
  13.        {
  14.            ...
  15.  
  16.            return list;
  17.        };
  18.        
  19. () =>
  20.    {
  21.        ...
  22.  
  23.        return list;
  24.    };
  25.        
  26. Func<List<int>> createList = () => { ... return list; };
  27. MyList = createList();
  28.        
  29. public static readonly List<int> MyList = new Func<List<int>>(
  30. () =>
  31. {
  32.     // Create your list here
  33.     return new List<int>();
  34. })();
  35.        
  36. public static readonly List<int> MyList = new Func<List<int>>(() => {
  37.     return new List<int>();
  38. })(); //<-- the parentheses that invoke
clone this paste RAW Paste Data