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
2
Question by tculig · Sep 17, 2013 at 10:34 PM · arraysizelength

I'm using .Length() with an array but there's some problem?

Hi all,

I'm baffled by this:

 childFragments.Length();

But it doesn't work! It doesn't even have .Length() as a supported function.

What gives??

Comment
Add comment · Show 5
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 Lo0NuhtiK · Sep 17, 2013 at 10:35 PM 1
Share

array.Length .... no ()

avatar image Fattie · Sep 18, 2013 at 09:09 AM 0
Share

@Hoe - that is an incredibly complicated way to say "Delete the brackets" :)

avatar image syclamoth · Sep 18, 2013 at 09:11 AM 1
Share

Complicated, but at least it explains the answer!

avatar image Hoeloe · Sep 18, 2013 at 09:14 AM 0
Share

@Fattie: I like to explain why you need to apply a fix, as well as just what you need to you ;)

avatar image Fattie · Sep 18, 2013 at 11:19 AM 1
Share

Indeed, "incredibly complicated" is not pejorative! ;-)

2 Replies

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

Answer by Hoeloe · Sep 17, 2013 at 11:39 PM

My guess is that you're more familiar with Java than C#, judging from this mistake (not Javascript, note).

C# supports properties, while Java does not. Properties are a neat language-level way of creating getters and setters without using separate functions for each.

This allows assignments like x += 4, where in Java, you would use: SetX(GetX()+4). Array Length is a read-only property in C#, and a getter method in Java. These are exactly the same semantically, but properties are implicit method calls, so do not use ().

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 syclamoth · Sep 18, 2013 at 09:16 AM 1
Share

Converted to answer because it answers the question better than the other contender, and already has more upvotes!

avatar image Fattie · Sep 18, 2013 at 11:20 AM 0
Share

It would be better with paragraph breaks.

avatar image
2

Answer by wiiarethesound · Sep 17, 2013 at 10:47 PM

childFragments.Length;

It's not a function, it's a variable :)

Comment
Add comment · Show 3 · 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 Bunny83 · Sep 17, 2013 at 11:32 PM 4
Share

it's not a variable, it's a property (which actually is a function but used like a variable) ;)

avatar image Fattie · Sep 18, 2013 at 09:10 AM 0
Share

it's totally awesome that such a simple question can provide so much entertainment value!!

avatar image robhuhn · Sep 18, 2013 at 11:54 AM 1
Share

ehem, 'actually' it's not a function, it's an accessor (which actually is a method ...) ;)

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

22 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Limiting size of data structures in editor 1 Answer

Why is this array out of length? 1 Answer

array.length read only? workaround? 2 Answers

Why Again Arrays In ExecuteInEditMode() Gives NullReferenceException Errors?? 1 Answer

Array.length edited using scripts 2 Answers


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