Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8922647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:53:46+00:00 2026-06-15T06:53:46+00:00

Possible Duplicate: count vs length vs size in a collection Array.Length vs Array.Count I

  • 0

Possible Duplicate:
count vs length vs size in a collection
Array.Length vs Array.Count

I declared this array:

int[] misInts = new Int[someNumber];

/* make some happy operations with the elements in misInts */

So I can get the value of SomeNumber with:
misInts.Length or misInts.Count()

Arrays in C# inherit from IEnumerable. So if I have:

Func<int> misIntsF = Enumerable.Range(0, someNumber).Select(c=> /* make some happy operations that return Integers */);

I am told that if I make misIntsF.Count() I actually execute the code in the Lambda expression, get the results and count them. But the array misInts doesn’t have a Lambda expressión.

Is misInts.Count() more memory consuming than misInts.Length? What are the differences between misInts.Count() and misInts.Length?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:53:48+00:00Added an answer on June 15, 2026 at 6:53 am

    array.Count() is actually a call to the Enumerable.Count<T>(IEnumerable<T>) extension method.

    Since this method takes an IEnumerable<T> (as opposed to ICollection<T>, which has a Count property), it needs to loop through the entire sequence to figure out how big it is.

    However, it actually checks whether the parameter implements ICollection<T> (which arrays do), and, if so, returns Count directly.
    Therefore, calling .Count() on an array isn’t much slower than .Length, although it will involve an extra typecast.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: count vs length vs size in a collection In Java in particular,
Possible Duplicate: Why is Array.Length an int, and not an uint Is there is
Possible Duplicate: create multiple variables based on an int count Objective C Equivalent of
Possible Duplicate: Length of Javascript Associative Array I have a JSON that looks like
Possible Duplicate: How to count JavaScript array objects? If it's not a JavaScript array,
Possible Duplicate: What's wrong with var x = new Array(); if (!Number.prototype.toZeroPaddedString) { Number.prototype.toZeroPaddedString
Possible Duplicate: how to count non-empty entries in php array? I want to count
Possible Duplicate: count duplicate elements in ruby array I just started learning ruby and
Possible Duplicate: Count number of values in array with a given value Let's say
Possible Duplicate: Count(*) vs Count(1) If I have a table, 'id' is primary key,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.