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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:53:57+00:00 2026-06-05T01:53:57+00:00

Something similar to linq find in which position is my object in List ,

  • 0

Something similar to linq find in which position is my object in List, except his accepted answer is evaluating at an object level.

Say I have

public interface IFoo{
    string text {get;set;}
    int number {get;set;}
}

and

public class Foo : IFoo{
    public string text {get;set;}
    public int number {get;set;}
}

Now I have a list collection of IFoo like so:

public IList<IFoo> Foos;

I want to write a method that brings back the index(es) of Foos based upon a property value and/ or values (for example, text or number in this case) so I can do something like:

var fooIndexes = Foos.GetIndexes( f => f.text == "foo" && f.number == 8 );

How would I write that?

  • 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-05T01:53:58+00:00Added an answer on June 5, 2026 at 1:53 am

    You could use something like:

    public static IEnumerable<int> GetIndices<T>(this IEnumerable<T> items, Func<T, bool> predicate)
    {
        return items.Select( (item, index) => new { Item = item, Index = index })
                         .Where(p => predicate(p.Item))
                         .Select(p => p.Index);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement something similar to IntegerAboveThresholdAttribute except that it should work
How can I do GroupBy multiple columns in LINQ Something similar to this in
(I've searched for something similar, but haven't found anything that matches and/or works) I
I am looking for something similar to array_chunk() but using an empty value as
I did something similar to: http://tympanus.net/codrops/2012/01/04/thumbnail-proximity-effect/ and just like the original it works in
I am creating something similar to a SplitFrameViewController, but with enough differences that I
I want to do something similar to summing 1/x from 1 to 100 without
I would do something similar to this in PHP: http://mysite.com/en/museum/gallery/garden http://mysite.com/es/museo/galeria/jardin It's possible? How
I have something similar to that: <table> <tr> <td>Hello,<br/>World!</td> </tr> </table> Both lines Hello,
I'm looking for something similar to the table creation form from phpmyadmin, but it

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.