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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:14:30+00:00 2026-05-31T13:14:30+00:00

Lets say I have List<string> = new List<string>() {20,26,32} I want to create a

  • 0

Lets say I have List<string> = new List<string>() {"20","26","32"}

I want to create a new List based on the first number in the previous list and it should have the same number of elements in it. I will be adding a certain number to that first number and so on and so on. As an example, using 6 as the number to add I would get 20,26,32. The resulting list will be List. The number 6 is a class wide property.

The issue comes if I have a list of “N”,”N”,”32″

I need to produce the same list of 20,26,32 but I have to use the last number to work out the others.

If I had “N”,”26″,”N” I would have to use the middle number to work out the others.

The N represents no data in the input list and it will always be this character

In summary, I need to produce a new list with the same number of elements as the input list and it must take the first or next numerical element to produce the resulting list using a specified number to add/subtract values to.

I wondered if LINQ’s aggregate function might be able to handle it but got a bit lost using it.

Examples:

"20","26","32" = 20,26,32
"N","26","32" = 20,26,32
"N","N","32" = 20,26,32
"20","26","N" = 20,26,32
  • 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-31T13:14:30+00:00Added an answer on May 31, 2026 at 1:14 pm

    What about something like this:

    var n = 6;
    
    List<string> strList = new List<string>() {"20","26","32"}; 
    // list can also be {null, "26", null} , {null, "N", "32"} , 
    //                  {"N", "26", null } etc...
    
    var list = strList.Select(s =>
    {
       int v;
       if(string.IsNullOrEmpty(s) || !int.TryParse(s,out v))
          return (int?)null;
       return v;
    });
    
    var firstValidVal = list.Select((Num, Index) => new { Num, Index })
                            .FirstOrDefault(x => x.Num.HasValue);
    if(firstValidVal == null)
        throw new Exception("No valid number found");
    
    var bases = Enumerable.Range(0, strList.Count).Select(i => i * n);
    int startVal = firstValidVal.Num.Value - bases.ElementAt(firstValidVal.Index);
    
    var completeSequence = bases.Select(x => x + startVal);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a list of objects of the same type. I want
Lets say that I have a generic collection in the string format. I want
Lets say i have the following unordered list <ul> <li><a>Hank</a></li> <li><a>Alice</a></li> <li><a>Tom</a></li> <li><a>Ashlee</a></li> </ul>
Lets say I have an entity Foo, and it contains a list of another
Lets say I have a database of widgets. I am showing a list of
Hey, Lets say we have a query which generates list of city names as
I have a ListBox bound to a list of Items (for arguement, lets say
Lets say I have an array like this: string [] Filelist = ... I
Let's say I have: public class Fruit { public static List<String> Suppliers { get;
I'm still new at this threading thingy. Lets say I have 50000 URLs 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.