ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 리스트의 아이템을 쪼개서 식구 늘이기
    android 2017. 9. 19. 15:45
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    List<string> orgList = new List<string>();
    orgList.Add("0");
    orgList.Add("1");
    orgList.Add("2");
    orgList.Add("3");
    orgList.Add("4");
    orgList.Add("5");
     
    List<Tuple<intList<string>>> haveList = new List<Tuple<intList<string>>>();
    List<string> tList;
     
    tList = new List<string>();
    tList.Add("0-1");
    tList.Add("0-2");
    tList.Add("0-3");
    haveList.Add(new Tuple<intList<string>>(0, tList));
     
    tList = new List<string>();
    tList.Add("2-1");
    tList.Add("2-2");
    tList.Add("2-3");
    haveList.Add(new Tuple<intList<string>>(2, tList));
     
    tList = new List<string>();
    tList.Add("5-1");
    tList.Add("5-2");
    tList.Add("5-3");
    haveList.Add(new Tuple<intList<string>>(5, tList));
     
    haveList.Reverse();
    foreach(var item in haveList)
    {
        orgList.InsertRange(item.Item1, item.Item2);
        orgList.RemoveAt(item.Item1 + item.Item2.Count());
    }
    cs


    결과

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    index[0] : 0-1
    index[1] : 0-2
    index[2] : 0-3
    index[3] : 1
    index[4] : 2-1
    index[5] : 2-2
    index[6] : 2-3
    index[7] : 3
    index[8] : 4
    index[9] : 5-1
    index[10] : 5-2
    index[11] : 5-3
    cs


    'android' 카테고리의 다른 글

    [CSV 파싱 1] 텍스트파일 한글 깨짐  (1) 2018.07.03
    2018 게임국가 기술자격검정  (0) 2018.07.03
    Hello World!!  (0) 2018.05.06
    First or Default 값 가져오기  (0) 2017.09.19
    double 문자열  (2) 2017.09.19
Designed by Tistory.