An array is a collection of similar objects. For example a satellite, a satellite collects on array of numbers. Just like in real life we can use an array in C#. In the coding universe everything is based around words, numbers, symbols and phrases. For an Array we would use numbers representing a collection of objects (assume the amount is the number). We can use an array to tell the amount of days in a week or how much ice cream cost per scoop. The way we would type an array is by first typing a type variable and placing a pair of brackets around them [ ]. The brackets are included to tell the code that it is an Array. After that you would provide the variable name followed by an equal sign. If you would like to put the choice of array numbers in the inspector then you must put public in front of your variable and conclude the statement with a semi colon. However if you would like to keep them in the Unity Inspector then you would have to add them all at once or add them later. To add them you must define the array by doing what we did above and putting and open brace after the equal sign. int [ ] myName = { . The open brace indicates the start of an array. Next you put all the items in the array separated by commas. When finished add a closing brace followed by a semi colon. If you would like to define them later you would have to tell the size of the array. Do the same thing above but instead of putting an open brace after the equal sign type new followed by the type you are using. After the type place the number in-between brackets followed by a semi colon. The number determines the size of your array.
Information on Arrays : ttps://app.schoology.com/assignment/1462465019/info
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |