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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:45:19+00:00 2026-05-26T03:45:19+00:00

I have a class that implements IEnumerable , but doesn’t implement IEnumerable<T> . I

  • 0

I have a class that implements IEnumerable, but doesn’t implement IEnumerable<T>. I can’t change this class, and I can’t use another class instead of it. As I’ve understood from MSDN LINQ can be used if class implements IEnumerable<T>. I’ve tried using instance.ToQueryable(), but it still doesn’t enable LINQ methods. I know for sure that this class can contain instances of only one type, so the class could implement IEnumerable<T>, but it just doesn’t. So what can I do to query this class using LINQ expressions?

  • 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-26T03:45:19+00:00Added an answer on May 26, 2026 at 3:45 am

    You can use Cast<T>() or OfType<T> to get a generic version of an IEnumerable that fully supports LINQ.

    Eg.

    IEnumerable objects = ...;
    IEnumerable<string> strings = objects.Cast<string>();
    

    Or if you don’t know what type it contains you can always do:

    IEnumerable<object> e = objects.Cast<object>();
    

    If your non-generic IEnumerable contains objects of various types and you are only interested in eg. the strings you can do:

    IEnumerable<string> strings = objects.OfType<string>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 instances of a class that implements the IEnumerable interface. I would
Let's say I have a class that implements the IDisposable interface. Something like this:
I have a custom class that implements that IComparable. This class is stored in
I have a custom class that implements ICollection , and this class is readonly,
I have a class that implements singleton pattern as you can see below: public
Say I have a class that implements IEnumerable<T> . It currently uses the yield
I've written a class that implements IEnumerable<T> . I have a method that returns
I have a class that implements multiple interfaces. I would like to register these
I have a class that implements the IDisposable interface. I am using a webclient
I have a class that implements properties in a specific way, to handle some

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.