백지부터 시작하는 이세계 코딩 생활

Unity Dictionary 를 활용한 중복처리 예시 본문

Unity

Unity Dictionary 를 활용한 중복처리 예시

조아덕 2022. 7. 13. 01:56
        string finalChars = string.Join(",", arrChar);
        string finalCharQies = string.Join(",", arrCharQty);
        string finalCharLv = string.Join(",", arrCharLv);

        foreach (var item in dicCardBoxItem)
        {
            if (arrChar.Contains(item.Key) == false)
            {
                dicCardBoxItem.TryGetValue(item.Key, out int charQty);

                finalChars = $"{finalChars},{item.Key}";
                finalCharQies = $"{finalCharQies},{charQty}";
                finalCharLv = $"{finalCharLv},1";
            }
            else
            {
                for (int i = 0; i < arrChar.Length; i++)
                {
                    if(arrChar[i].Equals(item.Key))
                    {
                        dicCardBoxItem.TryGetValue(item.Key, out int charQty);
                        arrCharQty[i] = (int.Parse(arrCharQty[i]) + charQty).ToString();
                        break;
                    }
                }
            }

'Unity' 카테고리의 다른 글

유니티 - 뒤끝 : 델리게이트 사용, 콜백처리  (0) 2022.02.13
Comments