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

  • Home
  • SEARCH
  • 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 4600828
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:44:22+00:00 2026-05-21T23:44:22+00:00

I have a collection of <int> s. 1 2 3 When I remove, for

  • 0

I have a collection of <int>s.

1
2
3

When I remove, for example, the 2, The collection becomes 1,3. However, when I go to add another item the list becomes

1
3
3

Because the sequence is based off the count of items in collection

Is there an easy way to resequence. The example above where I’m showing 1,3 should be resequence to 1,2 and then the next new item will be a 3.

  • 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-21T23:44:22+00:00Added an answer on May 21, 2026 at 11:44 pm

    You could rewrite your list every time you remove an object using Enumerable.Range, so the code to you would be something like this:

        //execute this after remove element
    void Resequence()
            {
                myList = Enumerable.Range(1, myList.Count).ToList();
            }
    

    so the add will be something like this

    void AddElement(){
       myList.Add(myList.Count + 1);
    }
    

    Note: in the add element you should remove the +1 if the list is zeroBased.

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

Sidebar

Related Questions

I have a collection like this List<int> {1,15,17,8,3}; how to get a flat string
I have the following List<int> collection and I need to find the highest integer
I have Collection List<Car> . How to compare each item from this collection with
I have a situation where I want to remove duplicates from a collection (list)
I have a list of User objects, and I have to remove ONE item
I have a simple Observable collection with two public properties, int ID and List
Suppose I have one list: IList<int> originalList = new List<int>(); originalList.add(1); originalList.add(5); originalList.add(10); And
I have class with collection as below public class MyClass:IXmlSerializable { int vesrion; private
I have a problem adding entities to a collection. public void SaveNotificationUsergroups(int bookingobjectID, int[]
I have a Dictionary<int, string> which I want to take the Key collection into

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.