Game Development Reference
In-Depth Information
36 Debug.Log (E.ID);
37 }
38 }
39 }
40 //----------------------------------------
More details on using List can be found in the topic's companion iles
(code bundle) at Chapter06\Collections . You can also see the
List class reference documentation in the MSDN at http://msdn.
microsoft.com/en-us/library/6sh2ey19%28v=vs.110%29.aspx .
The following are the comments for code sample 6-1:
Line 03 : To use the List class, you must include the System.Collections.
Generic namespace.
Line 06 : If your list data type is declared as a System.Serializable class,
then the list would be shown in the Object Inspector.
Line 20 : You can declare and initialize a new list instance in just one
statement inside the class members' declaration.
Line 27 : New objects are immediately added to the end of the list using the
Add method.
Line 30 : Items can be removed using several methods. RemoveRange lets
you delete several consecutive items from the list. Other removal methods
include Remove , RemoveAll , and RemoveAt .
Line 33 : You can cycle through all items in a list using a foreach loop.
Lines 27-33 : Generally, don't add or remove items to or from a list while
looping through it.
 
Search WWH ::




Custom Search