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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:20:11+00:00 2026-05-22T18:20:11+00:00

could someone help me with the linq statement, this is what i have so

  • 0

could someone help me with the linq statement,

this is what i have so far

public class Categories : ObservableCollection<Category>
{ 
    public Categories() { } 

    public int getBoardIndex(int BoardId)
    {
        return (from category in this
                from board in category.CategoryBoards
                where board.BoardId == BoardId
                select IndexOf(board)
                    );
    }
}

board is an item in category and when i pass a bordId ( which is not an index ) it must search for that BoardId in all boards in each category and then return the Index Of that board

how do i do it using Linq?

Thank you so much for all your help!!!

  • 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-22T18:20:12+00:00Added an answer on May 22, 2026 at 6:20 pm

    EDIT

    This is a much simpler version of the same thing:

    public int getBoardIndex(int BoardId)
    {
        return (from category in this
                from board in category.CategoryBoards
                where board.BoardId == BoardId
                select category.CategoryBoards.ToList().IndexOf(board)).FirstOrDefault();
    }
    

    Original Version

    To get the index of the first matching Board in its own Category, first find the Category, then get the index of the board:

    public int getBoardIndex(int BoardId)
    {
    
        var categoryBoard = (from category in this
                             from board in category.CategoryBoards
                             where board.BoardId == BoardId
                             select new {category, board}).FirstOrDefault();
        return categoryBoard.category.CategoryBoards.IndexOf(categoryBoard.board);
    }
    

    To get the index of the first matching Board in a flattened collection amongst all of the Categories, then @Dan Tao has the best answer.

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

Sidebar

Related Questions

Could someone help me on this, I have created simple web services using axis2
Could someone help explain this code to me? .text:00401270 ; int __cdecl main(int argc,const
Could someone help me converting this to LINQ? Any help/tips appreciated... IList<DestinationSummary> list =
Could someone help me on this, i have created simple webservices and it has
could someone help me on this problem, i want to access facebook API through
Could someone please help explain why I can't get this to work? I properly
I hope someone could help me on this. I want to add a month
may someone could help me on one problem in query LINQ to SQL Visual
Could someone help me to convert this rule for nginx? RewriteRule ^([^/]*)/([^/]*)/?$ index.php?a=$1&b=$2 [L,NC]
I wonder, if someone could help me... Is there a LINQ query that will

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.