Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 1.03 KB  |  hits: 11  |  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. convert List<List<object>> to IList<IList<object>>
  2. IList<IList<object>> ret = new List<IList<object>>();
  3.        
  4. // Or whatever
  5. ret.Add(new List<object>());
  6.        
  7. IList<IList<object>> p = new List<List<object>>();
  8.        
  9. List<List<object>> listOfLists = new List<List<object>>();
  10. IList<IList<object>> p = listOfLists;
  11. p.Add(new object[]);
  12. List<object> list = p[0];
  13.        
  14. var myOriginalList = new List<List<Object>>();
  15. var converted = ((IList<IList<Object>>)myOriginalList.Cast<IList<Object>>().ToList()); // EDIT: Added .ToList() here
  16.        
  17. IList<IList<object>> list = new List<IList<object>>(); // Works!
  18.        
  19. static IList<IList<object>> Test()
  20.     {
  21.         IList<IList<object>> result = new List<IList<object>>();
  22.         var item = new List<object>() { "one", "two", "three" };
  23.         result.Add(item);
  24.         return result;
  25.     }
  26.        
  27. public IList<IList<object>> Fetch(string data)
  28. {
  29.   IList<IList<object>> p = new List<IList<object>>();
  30.  
  31.   // add your stuff here
  32.  
  33.   return p;
  34. }
  35.        
  36. List<List<string>> list = new List<IList<string>>(); // DOES NOT COMPILE!!!!!