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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:27:33+00:00 2026-06-08T13:27:33+00:00

I m executing the follwing code: private static T FooException<T>(this IEnumerable<T> enum_in) { try

  • 0

I m executing the follwing code:

private static T FooException<T>(this IEnumerable<T> enum_in)    
{    
    try    
    {
        return enum_in.Single();
    }    
    catch(InvalidOperationException e)    
    {
        throw new XXXException(enum_in.Count(),  e   ...
    }    
}

and getting an InvalidOperationException.
If I have a look at enum.Count() then ther is exactly one item.
Thats what I don’t understand. Are there any cases where the enum can be with count = 1
and running in InvalidOperationException?

  • 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-08T13:27:35+00:00Added an answer on June 8, 2026 at 1:27 pm

    Not all implementations of Linq support all operations. Try using .First() instead.

    Edit: To answer the comments about this not being true. Firstly, we don’t know the concrete class of the variable, so even if you don’t know of any implementation for which Single is unsupported, that doesn’t mean it doesn’t exist.

    Furthermore I was thinking of the LINQ-To-Entity implementation. My source was the Microsoft Press book for exam 70-516, which on page 423 states that there are some unsupported methods connected to paging:

    Paging A paging operation returns a single, specific element from a sequence. The supported methods are First, FirstOrDefault, Skip and Take. The unsupported methods are ElementAt, ElementAtOrDefault, Last, LastOrDefault, Single, SingleOrDefault, SkipWhile and TakeWhile.

    All of the examples also use First rather than Single in that chapter, which is why I took extra note of this. It’s interresting that this contradicts the msdn documentation linked in the comments.

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

Sidebar

Related Questions

I am creating a logger in java by executing the following code: private static
I have this code: private static $dates = array( 'start' => mktime( 0, 0,
If I try executing the following code f = file('test','rb') fout = file('test.out','wb') for
I'm executing the following piece of code: ActivityManager actvityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List<RunningTaskInfo> procInfos
When I convert my VS2008 project to VS2010 the following code: private static readonly
Given the following code: static member private getIntValue (_map:Map<string, int>) (_key:string) = if (_map.ContainsKey
When executing the following code: OpenFileDialog dialog = new OpenFileDialog(); DialogResult result = dialog.ShowDialog();
I am executing the following code to install SQL Server 2012 in silent mode.
I am executing the following code: def takeN(s : String, n : Int): String
I am getting Incorrect syntax near the keyword 'select' after executing the following code.

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.