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
0
Question by Szmergiel · Apr 22, 2015 at 05:44 AM · arrayunity5issueadd

Unity 5 array.Add

Hello guys, it seems that this method does not anymore. Could someone tell me how to add an integer to the existing array without nothing between [] those?

 int[] tablica = new int[]{liczba1,liczba2};
 
 //then i want to add another integer
 
 tablica.Add(liczba3);
 
 // Does not work. I see a message:error CS1061: Type `int[]' does not contain a definition //for `Add' and no extension method `Add' of type `int[]' could be found (are you missing a //using directive or an assembly reference?)

Thank you for any reply.

Comment
Add comment · Show 1
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 AlwaysSunny · Apr 22, 2015 at 03:53 AM 0
Share

I'm not familiar with this extension. Is it part of Linq?

There's always: https://msdn.microsoft.com/en-us/library/vstudio/bb310854%28v=vs.100%29.aspx

Adding additional elements to an array is not a thing. Any extension method you may have used to achieve this in the past most definitely created a new array behind the scenes which was one element larger, then copied the contents of the original, then added the new element at the end. You could create such an extension yourself.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by gRntaus · Apr 22, 2015 at 06:23 AM

You are using a fixed length array and as a result you are not able to add anything to this without redefining it at a larger size and adding the new item to the end of the array.

You are probably wanting to use a List which has both variable length and access to the Add method ass seen on the provided link.

Comment
Add comment · 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Firebase - Unity Add/Push on Database 2 Answers

Need help with array script 1 Answer

Issue with Lerp and rigidbody in Unity5 0 Answers

Add custom declared variables in a Array 1 Answer

Inventory array add error 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