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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:17:25+00:00 2026-05-18T07:17:25+00:00

Is it possible for me to use LINQ in a way that allows me

  • 0

Is it possible for me to use LINQ in a way that allows me to determine that “9”
is the first missing value in the sorted list without using a for-loop and comparing each value to the one adjacent to it?

var listStringVals = new [] { "7", "13", "8", "12", "10", "11", "14" };
// sort list to "7","8","10","11","12","13","14"
var sortedList = listStringVals.OrderBy(c => int.Parse(c)).ToList();
// need some magic here to get the first gap in the sorted list
  • 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-18T07:17:26+00:00Added an answer on May 18, 2026 at 7:17 am

    Let

    var strings = new string[] { "7", "13", "8", "12", "10", "11", "14" };
    

    Then

    var list = Array.ConvertAll(strings, s => Int32.Parse(s)).OrderBy(i => i);
    // or
    var list = strings.Select(s => int.Parse(s)).OrderBy(i => i);
    // or
    var list = strings.OrderBy(s => int.Parse(s));
    

    (note this question)

    and then

    var result = Enumerable.Range(list.Min(), list.Count).Except(list).First(); // 9
    // or
    int min = list.Min(), max = list.Max();
    var result = Enumerable.Range(min, max - min + 1).Except(list).First();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Is there a LINQ way to go from a list of key/value
Is it possible to use LINQ in the express version of visual studio? I
I am wondering if it is possible to use Linq functionality to connect to
Is it possible to use all features of Linq to SQL for a MySQL
I am looking for a more sophisticated way of using Linq to SQL. I
Possible Duplicate: What is the LINQ way to implode/join a string array? Say I
I am working on a new project that needs to use Linq To SQL
Possible Duplicate: LINQ Partition List into Lists of 8 members how do I chunk
Is it possible use mod_rewrite to resolve addresses hosted on another server? Say I
Is it possible use a MySQL query to perform this kind of check? If

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.