code_junkie

C#: Is Implicit Arraylist assignment possible?

Nov 10th, 2011
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. int[] IntArray = {1,2,3};
  2.  
  3. object[] myArray = new object[] {1,2,3,"string1","string2"};
  4. ArrayList myArrayList = new ArrayList(myArray);
  5.  
  6. ArrayList list = new ArrayList {1,2,3};
  7.  
  8. List<int> list = new List<int>{1,2,3};
  9.  
  10. List<int> list = new List<int>(new int[] {1, 2, 3});
  11.  
  12. ArrayList list = new ArrayList(new object[] { 1, 2, 3, "string1", "string2"});
  13.  
  14. object[] values = { 1, 2, 3, "string1", "string2" };
  15. ArrayList AL = new ArrayList();
  16. AL = ArrayList.Adapter(values);
  17.  
  18. //or during intialization
  19. ArrayList AL2 = ArrayList.Adapter(values);
Add Comment
Please, Sign In to add comment