Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by MountDoomTeam · Oct 07, 2012 at 09:11 PM · arraylistlists

what are Lists?

It is written in somewhere that Lists are better compared to Arrays for ease of use.

Are they as fast? what are they? are they in unity 3? where can i read about Lists?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlucardJay · Oct 09, 2012 at 09:53 AM 0
Share

$$anonymous$$ore info :

http://wiki.unity3d.com/index.php?title=Which_$$anonymous$$ind_Of_Array_Or_Collection_Should_I_Use?

http://answers.unity3d.com/questions/327065/explanation-on-how-to-use-list-in-unityscript.html

avatar image whydoidoit · Oct 09, 2012 at 09:56 AM 0
Share

Nice link!

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by whydoidoit · Oct 07, 2012 at 09:33 PM

Lists are typesafe ways of producing a collection that can be modified at run time - increasing or decreasing the size. They are preferable to arrays because of typesafety, they also have a number of useful methods that can really speed things up. A List provides the same [] array access operator and can be used in place of arrays in many circumstances. Here is the documentation on lists http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx

Lists are very fast - adding to a list can cause the need for garbage collection however.

In C# you must add

   using System.Collections.Generic;

To your file and then you define a list like this:

    List<int> myIntList = new List<int>();
    List<MyOwnClass> myClassList = new List<MyOwnClass>();

In Javascript it works like this:

 var myOwnClass = new List.<MyOwnClass>();
 var myIntList = new List.<int>();

You can add elements using Add or AddRange - remove them using Remove and RemoveAt, access elements using myIntList[1], the number of elements in a list is stored in a Count property rather than Length. You can sort lists etc.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Oct 07, 2012 at 09:35 PM 1
Share

Lists are preferable to Arrays and ArrayList, but not to native arrays like int[10] if the array size is fixed.

avatar image MountDoomTeam · Oct 08, 2012 at 07:07 PM 0
Share

Thanks! i will learn them and then will post some code here :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with arrays in a list 1 Answer

Undo/back system using a List/Array 2 Answers

Copy values between two classes in two lists. 1 Answer

How to modify array values? 1 Answer

How can you do calculations on two lists? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges