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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:13:46+00:00 2026-06-07T06:13:46+00:00

I have some LINQ code that extracts bookmarks from PDFs that match a certain

  • 0

I have some LINQ code that extracts bookmarks from PDFs that match a certain naming convention (using Aspose.Pdf):

IOrderedEnumerable<Bookmark> magicBookmarks = (
    from    bookmark in allBookmarks.AsEnumerable()
    where   bookmark.Title.StartsWith(MAGIC_PHRASE) 
    // ...  other criteria
    orderby bookmark.PageNumber ascending
    select  bookmark
);

The Bookmark class has a property called PageNumber that gets the page number where a bookmark starts. In my situation, a bookmark can represent a section of 1…n pages.

What I’d like to do is transform this sequence into another sequence of Tuple<int, int> (or some comparable “pair” structure) where Item1 of each pair equals the PageNumber value of the corresponding element in the source sequence and Item2 equals the `PageNumber’ value of the next element in the source sequence minus 1 (for the sake of this exercise, assume that all Bookmarks in the source sequence occur in succession in the document from which they were extracted).

In short, I want the end result to be a sequence of pairs that represent the start and end pages of each bookmarked PDF section.

  • 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-07T06:13:47+00:00Added an answer on June 7, 2026 at 6:13 am

    You could use Enumerable.Zip for this by zipping the enumeration with itself just skipping the first element:

    var results = magicBookmarks.Zip(magicBookmarks.Skip(1), 
                                     (a, b) => new 
                                               { 
                                                 PageNumber = a.PageNumber, 
                                                 PageNumberNext = b.PageNumber - 1 
                                               });
    
    foreach (var item in results)
    {
        Console.WriteLine("Page: {0}, Next: {1}", item.PageNumber, item.PageNumberNext);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some existing code that retrieves data from a database using ADO.NET that
I have some LINQ code that generates a list of strings, like this: var
I have some code where I am using a Linq-To-SQL DataContext to add and
I have some e-commerce code that I use often that uses Linq To SQL
I have some asp.net code that populates the fields in a LINQ to SQL
I have some Linq code and it's working fine. It's a query that has
I have some Linq code, that works fine. It retrieves a list of board
I have code that is using a win32 api from a web app. I
Can I have some help in improving this linq. I'm basically returning speakers from
I have a LINQ query that returns some object like this... var query =

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.