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 9002803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:37:10+00:00 2026-06-16T00:37:10+00:00

A Group of objects. However i am having confusion in the following case. A

  • 0

A Group of objects. However i am having confusion in the following case.

A sample class

class A
{
     public string Foo{get; set;}
}

class A_list
{
     public A[] list;
     public A_list(A[] _list)
     {
        list = new A[_list.Length];
        for (int i = 0; i < _list.Length; i++)
        {
            list[i] = _list[i];
        }
    }
}

static void Main(String[] args)
{
    A[] names = new A[3]
        {
            new A{Foo="some"},
            new A{Foo="another"},
            new A{Foo="one"}
        };

    A_list just_an_object = new A_list(names);
 }

Which of the above is a custom collection the array or the object that holds array as a field or are both custom collections.

  • 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-16T00:37:11+00:00Added an answer on June 16, 2026 at 12:37 am

    Describing a collection as a “group of objects” is technically right but also a bit too reductive. A better question would be “what’s a useful collection?”, where the “useful” brings you to asking yourself “how do I need to use it”?

    Now, the Array field in A_List is definitely a collection (but not a “custom” one), while your A_List is (arguably) a collection, but is it a useful one?

    A collection is a group of generally related objects that you put together in order to generalize some operation on all of them. The ways you may want to use the collection are many, but the most common ones have been pretty much standardized in many programming languages.
    For instance, in order for a collection to be “useful” you generally need at least to be able to read its elements in a forward-only loop from the first to the last.
    Your A_List does not provide this directly. You could easily add custom methods to do so, but you could go a step ahead and implement an existing interface.

    If you implemented IEnumerable<T> on A_List you would not only be able to iterate through it, but could also use your A_List interchangeably with other collections in a lot of existing code that expects a IEnumerable. For example:

    class A_list : IEnumerable<A>
    {
                // ... your other code
    
        public IEnumerator<A> GetEnumerator()
        {
            return ((IEnumerable<A>)list).GetEnumerator();
        }
    
    
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return list.GetEnumerator();
        }
    }
    

    would allow you to do this in your main:

    foreach(var a in just_an_object)
    {
        Console.WriteLine(a.Foo);
    }
    

    Or you could use it with Linq:

    var numbered=just_an_object.Zip(Enumerable.Range(0,3),(a,b) => b.ToString() + a.Foo);
    

    Now numbered is a IEnumerable<String> with three values (0some, 1another, 2one), but this is unimportant; the important bit is that (by implementing IEnumerable<T>) just_an_object could be used with a Linq method that works in the same way with an Array or a List or most other “standard” collections.
    And also, note that neither foreach nor Zip needed to know that your list field is an Array and not a List<A> or a red-black tree you implemented yourself, so you may want to make it private.

    There are other things,besides iterating through it, that you may want to do with a collection. Adding or removing elements, providing a indexer (so that you can access the n-th element with just_an_object[n] ). As with IEnumerable, there are interfaces that enable you to implement them in a “standardized” way (look for ICollection and IList).

    And then there are the “custom” aspects. The ones that made you decide that you needed your custom collection instead of directly using Array or List that already do all these things for you out-of-the-box…

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

Sidebar

Related Questions

I have a set of objects I want to group in Linq. However the
struct Group { Group(string _N, set <string> M_) {Name = N_; Member = M_}
In my app, I have a group of 3d objects and they're exposed to
I'm loading lots of User and related Group objects from a custom PDO query
I know that reusing UITableViewCell objects is key to increase UITableView performance. However I
I am trying to create a group of draggable DOM objects using jQuery UI's
I have the following code: var foo = (from data in pivotedData.AsEnumerable() select new
I'm serializing a large number of objects to binary files, however I want to
I'm having trouble defining a group generic within an R package that I'm writing.
I'm having some troubles with ending a group of dynamically created threads. The reason

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.