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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:39:27+00:00 2026-05-15T09:39:27+00:00

I have created a subclass of a generic list so that I could implement

  • 0

I have created a subclass of a generic list so that I could implement a new interface

public class CustomersCollection : List<Customer>, IEnumerable<SqlDataRecord>
{
...
}

When I change the field definition to the new class (see example of old and new lines below) I get all sorts of compile errors on things that should exist in the original list.

public CustomersCollection Customers { get; set; } 
public void Sample()
{
    Console.WriteLine(Customers.Where(x=>x.condition).First().ToString());
}

Why does CustomersCollection does not inherit the IQueryable, IEnumerable interface implementations for List?

The official error is:

‘CustomersCollection’ does not contain
a definition for ‘Where’ and no
extension method ‘Where’ accepting a
first argument of type
‘CustomersCollection’ could be found
(are you missing a using directive or
an assembly reference?)


It turns out that the custom implementation of IEnumerable causes all the extension methods that apply to IEnumerable to fail. Whats going on here?

  • 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-05-15T09:39:27+00:00Added an answer on May 15, 2026 at 9:39 am

    The extension methods are available to a class that inherits from List<T>. Perhaps you need to add using System.Linq; to your code file? Also check that you have a reference to System.Core.dll.

    Edit

    Since you have List<U> and IEnumerable<T> being inherited/implemented by the same class, you need to provide the type when you use the extension methods. Example:

    CustomerCollection customers = new CustomerCollection();
    customers.Add(new Customer() { Name = "Adam" });
    customers.Add(new Customer() { Name = "Bonita" });
    foreach (Customer c in customers.Where<Customer>(c => c.Name == "Adam"))
    {
        Console.WriteLine(c.Name);
    }
    

    … based on

    class Customer { public string Name { get; set; } }    
    
    class Foo { }
    
    class CustomerCollection : List<Customer>, IEnumerable<Foo>
    {
        private IList<Foo> foos = new List<Foo>();
    
        public new IEnumerator<Foo> GetEnumerator()
        {
            return foos.GetEnumerator();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a subclass of UITableViewController that is used as the custom class
I have created a subclass of QGLwidget and I was hoping that I could
I have created a subclass of the TextBox class so that I can capture
I have created a custom subclass of UIView for an interface element that I
I have created a UIView subclass in order to implement a custom drawRect method.
I have the following structure: abstract class Base { public abstract List<...> Get(); //What
I have an interesting problem. I'd like to create a generic class that can
Let's say I have two constructors in my class: public User (List<Source1> source){ ...
I have created a subclass of UIImageView and I am handling the touches for
I have created a custom subclass of UITableViewCell. There, I allow the user to

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.