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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:08:14+00:00 2026-05-20T12:08:14+00:00

I am pretty confused in collection and IEnumerable types. Can any one explain why

  • 0

I am pretty confused in collection and IEnumerable types. Can any one explain why the 1st query is wrong but the 2nd is correct-
1st- this gives error

ConditionFieldCollection conditionColl = (ConditionFieldCollection)Session["ConditionFieldCollection"];
ConditionFieldCollection cnd = new ConditionFieldCollection(); 
cnd = (from c in conditionColl
            where iq.QueryField == c.Expression
                select c);

2nd – works fine

ConditionFieldCollection conditionColl = (ConditionFieldCollection)Session["ConditionFieldCollection"];
List<ConditionField> cnd = (from c in conditionColl.OfType<ConditionField>()
                                       where iq.QueryField == c.Expression
                                       select c).ToList();

I know LINQ returns IEnumerable type of collection object but ConditionFieldCollection is also a Collection then why it gives me error at compile time. Is there any difference b/w Collecton and IEnumerable Collection??

  • 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-20T12:08:15+00:00Added an answer on May 20, 2026 at 12:08 pm

    You are attempting to assign an IEnumerable<ConditionField> to a variable with type ConditionFieldCollection – that can’t work. An enumerable is not a collection, and certainly isn’t that specific collection.

    Many collections allow an enumerable constructor, so this may work:

    ConditionFieldCollection cnd = new ConditionFieldCollection(
        from c in conditionColl
        where iq.QueryField == c.Expression
        select c);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty confused by one of the subtleties of the vimscript extend() function. If
This seems like it should be pretty straight forward, but I'm apparently confused. I
might be a stupid question but I seem to be confused. Im pretty new
Ok, so fb_graph looks pretty simple to use but Im kinda confused as how
Pretty much the same as this question. But I can't seem to get this
i have readed many topic but i'm pretty confused. it seems that: if ([[UIScreen
I am using a wrapper but I am pretty confused. I want the two
I'm pretty confused about this one. Given the following xml: <sch:eventList> <sch:event> <sch:eventName>Event One</sch:eventName>
I'm pretty new to Scala, but I thought that one of the strengths of
I'm pretty confused with the behaviour of arrays of strings when I loop them

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.