Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to Get all the rest values except the first 4 in a list, Need Help!

Discussion in 'Scripting' started by gsammbunny, Oct 19, 2018.

  1. gsammbunny

    gsammbunny

    Joined:
    Mar 7, 2016
    Posts:
    66
    I got two lists:
    • BastList & BaseListB
    • BaseListB has 10 values
    • BaseList.AddRange(BaseListB.Take(4)); // Took first 4 values from BaseListB and Added to BaseList
    Now I have another List i.e BaseList2
    • BaseList2.AddRange(BaseListB.Take(?); // My Concerned Part
    How to Take the Values other than first 4 in adjacent order like Take(4) does

    I'd really appreciate a code explanation for this scenario.
     
  2. barskey

    barskey

    Joined:
    Nov 19, 2017
    Posts:
    207
    Can you use
    BaseList2.AddRange (BaseListB.Skip(4).Take (BaseListB.Count - 4);
    ?
     
    gsammbunny likes this.
  3. SVKsuli

    SVKsuli

    Joined:
    Mar 23, 2014
    Posts:
    63
    You need to use AddRange? you can just use for loop to control what you want to add and what not.