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

  • Home
  • SEARCH
  • 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 396803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:35:17+00:00 2026-05-12T16:35:17+00:00

I took the following example from Jrista’s answer to a post. Finding Twentyone count

  • 0

I took the following example from Jrista’s answer to a post.

Finding Twentyone count

int[] numbers = new[] { 1, 3, 11, 21, 9, 23, 7, 4, 18, 7, 7, 3, 21 };

var twentyoneCount = numbers.Where(n => n == 21).Count();

Suppose i use “Func” delegate how can i get the count ?

I tried as (pardon me for the bad syntax)

var otherway= Func  <int> numbers= x => x==21;

  • 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-12T16:35:17+00:00Added an answer on May 12, 2026 at 4:35 pm

    You are using an anonymous delegate with the same signature as Func<int, bool> right now. If you wanted to use a method instead, you could write:

    // a method that takes int and returns bool is
    // a Func<int, bool> delegate
    public bool IsEqualTo21(int x)
    { 
        return (x == 21);
    }
    

    And then use it as:

    var twentyoneCount = numbers.Where(IsEqualTo21).Count();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I took the following code from the examples page on Asio class tcp_connection :
I have the following text from an academic course I took a while ago
If I have the following example file where each number is represents a byte
I need to calculate the directory size in VB .Net I know the following
I am working on a project that is using NetTcp bindings for talking to
I'm currently having an issue wrapping my brain around the notion of converting my
my first question here: I am having trouble using libcURL in a c++ project.
Possible Duplicate: Why do some websites add “Slugs” to the end of URLs? This
I have a few questions (so far) with the the LocationManager on Android and

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.