Unity¤Ë´ØÏ¢¤¹¤ëµ­»ö¤Ç¤¹

¡¡°ú¤­Â³¤­¡¢¥²¡¼¥àÆâ¤Ç¼èÆÀ¤·¤¿É¬ÍפʾðÊó¤ò¡¢¾ðÊ󤴤Ȥ˥»¡¼¥Ö¡¦¥í¡¼¥É¤¹¤ë¤¿¤á¤Îµ¡Ç½¤ò¼ÂÁõ¤·¤Þ¤¹¡£
¤³¤Î¼ê½ç¤Ç¤Ï¡¢List ¤Î¾ðÊó¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤¹¤ë¤¿¤á¤Îµ¡Ç½¤ò¼ÂÁõ¤·¤Þ¤¹¡£



ȯŸ£²£²¡¡¡¼¥»¡¼¥Ö¡¦¥í¡¼¥Éµ¡Ç½¤Î¼ÂÁõ­¢¡¼



¡¡¿·¤·¤¤³Ø½¬ÆâÍƤϡ¢°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£

¡¡¡¦String.Split ¥á¥½¥Ã¥É¤È StringSplitOptions Îóµó·¿
¡¡¡¦Linq¤Îµ¡Ç½¤Î¼ÂÁõÎã­¢¡¡¡ÁAggregate ¥á¥½¥Ã¥É¡¢ToList ¥á¥½¥Ã¥É¡Á
¡¡¡¦List¤Î»È¤¤Êý­£¡¡¡¼ConvertAll ¥á¥½¥Ã¥É¡¼



£±¡¥Àß·×


¡¡Á°²ó¤Î¼ê½ç¤Ç¤Ï int ·¿¤Î¥¯¥ê¥¢¥Ý¥¤¥ó¥È¤Î¾ðÊó¤ò PlayerPrefs ¥¯¥é¥¹¤Î SetInt ¥á¥½¥Ã¥É¤È GetInt ¥á¥½¥Ã¥É¤ò ³èÍѤ·¡¢¥»¡¼¥Ö¡¦¥í¡¼¥Éµ¡Ç½¤ò¼ÂÁõ¤·¤Þ¤·¤¿¡£
¤³¤Î¼ê½ç¤Ç¤Ï¡¢¥¯¥ê¥¢¥Ý¥¤¥ó¥È¤Î¾¤Ë¤â¥»¡¼¥Ö¡¦¥í¡¼¥É¤ò¹Ô¤¤¤¿¤¤¾ðÊó¤ò¹Í¤¨¤Æ¡¢¤½¤ÎÊÑ¿ô¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤¹¤ëµ¡Ç½¤ò¼ÂÁõ¤¹¤ëÀ߷פò¹Í¤¨¤Æ¤¤¤­¤Þ¤¹¡£



¡¡¸½ºß¥æ¡¼¥¶¡¼¤Î¾ðÊó¤È¤·¤Æ¥»¡¼¥Ö¤·¤Æ¤ª¤­¤¿¤¤¾ðÊó¤È¤·¤Æ¤Ï¡¢¥¯¥ê¥¢¤·¤¿¥¹¥Æ¡¼¥¸¤Î¾ðÊó¤È¡¢½ê»ý¤·¤Æ¤¤¤ëÉð´ï¤Î¾ðÊ󤬤¢¤²¤é¤ì¤Þ¤¹¡£
¤É¤Á¤é¤Î¾ðÊó¤â·¿¤Ï°Û¤Ê¤ê¤Þ¤¹¤¬¡¢¤¤¤º¤ì¤Î¾ðÊó¤â List ¤ò³èÍѤ·¤Æ´ÉÍý¤ò¤ª¤³¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£

¡¡PlayerPrefs ¥¯¥é¥¹¤Ë¤Ï int ·¿¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤¹¤ë¥á¥½¥Ã¥É¤Ï¤¢¤ê¤Þ¤¹¤¬¡¢List ·¿¤ò¤½¤Î¤Þ¤Þ¥»¡¼¥Ö¡¦¥í¡¼¥É¤¹¤ëµ¡Ç½¤Ï¤¢¤ê¤Þ¤»¤ó¡£
¤Ä¤Þ¤ê¡¢List<int> ·¿¤ä List<WeaponData> ·¿¤ò¤½¤Î¤Þ¤Þ¤Î¾õÂ֤Ǥϥ»¡¼¥Ö¡¦¥í¡¼¥É¤¬¤Ç¤­¤Ê¤¤¤¿¤á¡¢
¥»¡¼¥Ö¡¦¥í¡¼¥É¤¬¹Ô¤¨¤ë¤è¤¦¤Ë½èÍý¤ò¹Í¤¨¤Æ¾¯¤·¼ê¤ò²Ã¤¨¤Æ¤¢¤²¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

¡¡¤³¤Î¤è¤¦¤Ê¤È¤­¤Ë¤Ï¤¤¤¯¤Ä¤«¤ÎÊýË¡¤¬¹Í¤¨¤é¤ì¤Þ¤¹¡£(¾¤Ë¤â¤¢¤ê¤Þ¤¹)

¡ã·¿¤¬°Û¤Ê¤ëºÝ¤Î¥»¡¼¥Ö¤ÎÊýË¡¤ÎÎã¡ä
¡¡£±¡¥List ¤ÎÍ×ÁÇ(Ãæ¿È)¤ò£±¤Ä¤º¤Ä¼è¤ê½Ð¤·¤Æ¡¢int ·¿¤È¤·¤Æ£±¤Ä¤º¤Ä¡¢¥»¡¼¥Ö¡¦¥í¡¼¥É¤ò¹Ô¤¦
¡¡£²¡¥Êݸ¤·¤¿¤¤¥Ç¡¼¥¿¤Î·¿¤Îºî¤ê¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤¬¹Ô¤¨¤ë·¿¤ËÊѹ¹¤·¤Æ¤«¤é¡¢¥»¡¼¥Ö¡¦¥í¡¼¥É¤ò¹Ô¤¦

¡¡º£²ó¤Ï¡Ú£²¡Û¤ÎÊýË¡¤òºÎÍѤ·¡¢¤Þ¤º¤Ï List<int>¡¡·¿¤Î¾ðÊó¤Ç´ÉÍý¤·¤Æ¤¤¤ë¡¢¥¯¥ê¥¢¤·¤¿¥¹¥Æ¡¼¥¸¤Î¾ðÊó¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤¹¤ëµ¡Ç½¤ò¼ÂÁõ¤·¤Æ¤¤¤­¤Þ¤¹¡£



¡¡»²¹Í¤Þ¤Ç¤Ë¤Ç¤¹¤¬¡¢¡Ú£±¡Û¤ÎÊýË¡¤ò²òÀ⤷¤Æ¤ª¤­¤Þ¤¹¡£
for ʸ¤ä foreach ʸ¤Ê¤É¤ò³èÍѤ·¤Æ¡¢List ¤ÎºÇÂçÃͤòÌÜɸÃͤ˷«¤êÊÖ¤·¤Î½èÍý¤òºî¤ê¡¢½èÍý¤ÎÃæ¤Ç¡¢List ¤Î³ÆÍ×ÁǤ˽çÈ֤˥¢¥¯¥»¥¹¤·¤Æ¡¢¤½¤ì¤ò int ·¿¤Ç¥»¡¼¥Ö¤ò¹Ô¤¤¤Þ¤¹¡£
¥í¡¼¥É¤¹¤ë¾ì¹ç¤âƱÍͤǡ¢int ·¿¤Î¾ðÊó¤ò¥í¡¼¥É¤·¤Æ¡¢¤½¤ì¤ò List ¤Ë½çÈÖ¤ËÄɲ乤뤳¤È¤ÇÉü¸µ¤·¤Þ¤¹¡£¤³¤ì¤Ï¡¢List ¤Ç´ÉÍý¤·¤Æ¤¤¤ë·¿¤¬¥»¡¼¥Ö¡¦¥í¡¼¥É¤Ç¤­¤ë·¿¤Ç¤¢¤ë¾ì¹ç¤Ë¤Î¤ß¼ÂÁõ½ÐÍè¤Þ¤¹¡£

¡¡¤¿¤À¤·¡¢¤³¤Î¼ÂÁõ¤Î¾ì¹ç¡¢¥»¡¼¥Ö¡¦¥í¡¼¥ÉÍѤΠKey ¤¬³ÆÃͤ´¤È¤ËɬÍפˤʤê¤Þ¤¹¡£Î㤨¤Ð¡¢List ¤ÎÍ×ÁÇ¿ô¤¬ 5 ¸Ä¤¢¤ë¾ì¹ç¡¢5 ¤Ä¤Î¥»¡¼¥Ö¡¦¥í¡¼¥ÉÍѤΠKey ¤¬É¬Íפˤʤê¤Þ¤¹¡£
¤³¤Î¤è¤¦¤Ê¾ì¹ç¤Ï¡¢£±¤Ä¤Î Key ÍѤÎʸ»úÎó¤òºîÀ®¤·¡¢Ê¸»ú¤ÎºÇ¸å¤ËÄ̤·ÈÖ¹æ¤òºÎÈÖ¤¹¤ë¤³¤È¤Ç³ÆÃͤΥ»¡¼¥Ö¡¦¥í¡¼¥ÉÍѤΠKey ¤ò¼«Æ°Åª¤ËºîÀ®¤Ç¤­¤Þ¤¹¡£


¡ãfor ʸ¤ò³èÍѤ·¤Æ List ¤Î¾ðÊó¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤¹¤ë¾ì¹ç¤Î¼ÂÁõÎã¡ä

    private const string CLEAR_STAGE_NO_KEY = "clearStageNo";      // ¥¯¥ê¥¢¤·¤¿¥¹¥Æ¡¼¥¸¤ÎÈÖ¹æÍѤΥ»¡¼¥Ö¡¦¥í¡¼¥ÉÍѤΠKey(¤³¤Î¤Þ¤Þ¤À¤È£±¤Ä¤·¤«¥»¡¼¥Ö¤Ç¤­¤Ê¤¤¤Î¤Ç¡¢ºÇ¸å¤ËÈÖ¹æ¤òÄɲ乤ë)

// ¥»¡¼¥Ö
public void SaveClearStageNoListToInt() {

    // ·ÀÌó¤·¤¿¥­¥ã¥é¤Î List ¤«¤éÍ×ÁǤò 1¤Ä¤º¤Ä¼è¤ê½Ð¤¹
    for (int i = 0; i < clearStageNoList.Count; i++) {

        // £±¤Ä¤º¤Ä¥»¡¼¥Ö¤¹¤ë¤¿¤á¤Ë Key ¤ËºÎÈÖ¤·¡¢¥»¡¼¥Ö¤¹¤ëÃͤòÀßÄê
        PlayerPrefs.SetInt(CLEAR_STAGE_NO_KEY + clearStageNoList[i].ToString(), clearStageNoList[i]);

        // clearStageNo_0¡¢ clearStageNo_1 ¤Î¤è¤¦¤Ê·Á¤Ç¥»¡¼¥Ö¤µ¤ì¤Þ¤¹¤Î¤Ç¡¢¥í¡¼¥É¤¹¤ë¾ì¹ç¤â¡¢clearStageNo_0 ¤Î¤è¤¦¤Ë¡¢ºÇ¸å¤ËÈÖ¹æ¤òÉÕ¤±¤ëɬÍפ¬¤¢¤ê¤Þ¤¹
    }

    // SetInt ¥á¥½¥Ã¥É¤Î¾ðÊó¤ò¤¹¤Ù¤Æ¥»¡¼¥Ö
    PlayerPrefs.Save();
}

// ¥í¡¼¥É
public void LoadClearStageNoListToInt() {

    // ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥­¥ã¥é¤Î¥Ç¡¼¥¿¿ô¤òÌÜɸÃͤ˷«¤êÊÖ¤¹
    for (int i = 0; i < DataBaseManager.instane.stageDataSO.stageDataList.Count; i++) {

        // ¥»¡¼¥Ö¤µ¤ì¤Æ¤¤¤ë Key ¤¬¤¢¤ë¤«³Îǧ
        if (PlayerPrefs.HasKey(ENGAGE_CHARA_KEY + i)) {

            // ¥í¡¼¥É¤·¤Æ List ¤ËÄɲÃ
            clearStageNoList.Add(PlayerPrefs.GetInt(CLEAR_STAGE_NO_KEY + i));

        }
    }
}



¡¡¡Ú£²¡¥Êݸ¤·¤¿¤¤¥Ç¡¼¥¿¤Î·¿¤Îºî¤ê¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤¬¹Ô¤¨¤ë·¿¤ËÊѹ¹¤·¤Æ¤«¤é¡¢¥»¡¼¥Ö¡¦¥í¡¼¥É¤ò¹Ô¤¦¡ÛÊýË¡¤Ë¤Ä¤¤¤Æ¤ÎÀ߷פιͤ¨Êý¤Ç¤¹¡£

¡¡·¿¤Îºî¤ê¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤¬¹Ô¤¨¤ë·¿¤ËÊѹ¹¤¹¤ë¡¢¤È¤¤¤¦Éôʬ¤Ç¤¹¤¬¡¢PlayerPrefs ¥¯¥é¥¹¤Ç¤Ï£³¤Ä¤Î·¿¤Ç¤Î¥»¡¼¥Ö¡¦¥í¡¼¥É¤¬²Äǽ¤Ç¤¹¡£
List ¤Î¾ðÊó¤Ï int ·¿¤Ç¤¹¤¬¡¢¤³¤Î¾ðÊó¤ò¡¢ÃÍ(Í×ÁÇ)¤´¤È¤Ë¥«¥ó¥Þ¤Ç¶èÀÚ¤é¤ì¤¿£±¹Ô¤Îʸ»úÎó¤È¤·¤Æ¿·¤·¤¯ÊÑ¿ô¤òºîÀ®¤¹¤ë ¤è¤¦¤Ë¤·¤Þ¤¹¡£

¡ãList<int> ¤ò¥«¥ó¥Þ¶èÀÚ¤ê¤Î string ·¿¤Ë¤¹¤ë¡ä
  List¡ãint¡ä clearStageNoList = new List<int>();

clearStageNoList[0] = 0;
clearStageNoList[1] = 1;
clearStageNoList[2] = 2;
clearStageNoList[3] = 3;

¡¡¡¡¢­

  // List<int> ¤ò ¥«¥ó¥Þ¶èÀÚ¤ê¤Î 1¹Ô¤Î string ·¿¤Ë¤¹¤ë
  string saveStr = "0, 1, 2, 3,";

¡¡¤³¤Î¤è¤¦¤Ë¡¢¾ðÊó¤ò½ñ¤­´¹¤¨¤Æ¤¢¤²¤ë¤³¤È¤Ç¡¢PlayerPrefs ¥¯¥é¥¹¤Î¥»¡¼¥Ö¡¦¥í¡¼¥É¤¬¤Ç¤­¤ë string ·¿¤Ë¤Ê¤ê¤Þ¤¹¤Î¤Ç¡¢
¥»¡¼¥Ö¤ò¹Ô¤¦ºÝ¤Ë string ·¿¤Ë¤·¤ÆÊݸ¤·¡¢¥í¡¼¥É¤ò¹Ô¤¦ºÝ¤Ë¤Ï¤³¤Î string ·¿¤Ç¥í¡¼¥É¤·¤Æ¡¢¤½¤Î¾ðÊó¤ò¸µ¤Î·¿¤Î¾ðÊó¤ËÌ᤹¤³¤È¤Ç¡¢
PlayerPrefs ¥¯¥é¥¹¤òÍøÍѤ·¤Æ¥»¡¼¥Ö¤È¥í¡¼¥É¤¬¹Ô¤¨¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£



¡¡½èÍý¤Îή¤ì¤ò¤Þ¤È¤á¤Þ¤¹¡£

¡ã¥»¡¼¥Ö¤¹¤ë¤È¤­¡ä
¡¡¡¦¥»¡¼¥Ö¤·¤¿¤¤¾ðÊó(¥¯¥é¥¹¡¦·¿)¤¬ PlayerPrefs ¥¯¥é¥¹¤ËÂбþ¤·¤Æ¤¤¤ë·¿¤Ç¤Ï¤Ê¤¤¤¿¤á¡¢¤½¤Î¤Þ¤Þ¤Ç¤Ï List<int> ·¿¤ÎÊÑ¿ô¤ÎÃͤò¥»¡¼¥Ö¡¦¥í¡¼¥É¤Ç¤­¤Ê¤¤¡£
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢­
¡¡¡¦List<int> ·¿¤Î¾ðÊó¤ò£±¤Ä¤º¤Ä¼è¤ê½Ð¤·¤Æ¡¢ÃͤÈÃͤȤò¥«¥ó¥Þ¤Ç¶èÀڤä¿£±¹Ô¤Îʸ»úÎó¤È¤·¤ÆºîÀ®¤·¡¢¥»¡¼¥Ö¤·¤¿¤¤¾ðÊó¤ò string ·¿¤Î¾ðÊó¤ËÊÑ´¹¤¹¤ë¡£
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢­
¡¡¡¦¤³¤Î string ·¿¤Î¾ðÊó¤ò PlayerPrefs ¥¯¥é¥¹¤Î SetString ¥á¥½¥Ã¥É¤È Save ¥á¥½¥Ã¥É¤òÍøÍѤ·¤Æ¥»¡¼¥Ö¤¹¤ë¡£

¡ã¥í¡¼¥É¤¹¤ë¤È¤­¡ä
¡¡¡¦string ·¿¤Ç¥»¡¼¥Ö¤·¤Æ¤¢¤ë¾ðÊó¤ò PlayerPrefs ¥¯¥é¥¹¤Î GetString ¥á¥½¥Ã¥É¤òÍøÍѤ·¤Æ¥í¡¼¥É¤ò¤¹¤ë¡£
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢­
¡¡¡¦¥í¡¼¥É¤·¤¿¾ðÊó(¥¯¥é¥¹¡¦·¿)¤¬ string ·¿¤Î¤¿¤á¡¢¤½¤Î¤Þ¤Þ¤Ç¤Ï¥»¡¼¥Ö¤¹¤ëÁ°¤Î¾ðÊó(º£²ó¤Ï List<int> ·¿)¤È¤·¤Æ³èÍѤǤ­¤Ê¤¤¡£
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢­
¡¡¡¦¥í¡¼¥É¤·¤¿¾ðÊó¤ò¥«¥ó¥Þ¤Î°ÌÃ֤ǶèÀڤäơ¢List<int> ·¿¤ÎÃͤȤ·¤Æ£±¤Ä½çÈ֤˼è¤ê½Ð¤¹¡£¤½¤ÎºÝ¤Ë¡¢string ·¿¤ò int ·¿¤ËÊÑ´¹¤·¤Æ List ¤ËÄɲ乤뤳¤È¤Ç¾ðÊó¤òÉü¸µ¤¹¤ë¡£
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢­
¡¡¡¦¥»¡¼¥Ö¤¹¤ëºÝ¤Î¾ðÊó(¥¯¥é¥¹)¤ËÉü¸µ¤µ¤ì¤ë¤Î¤Ç¡¢¤³¤Î¾ðÊó¤ò¤Þ¤¿¥²¡¼¥à¤ÇÍøÍѤ¹¤ë


£²¡¥GameData ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤¹¤ë


¡¡List<int> ·¿¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤ò¹Ô¤¨¤ë string ·¿¤Ë¤·¤Æ¤«¤é½èÍý¤ò¹Ô¤¦µ¡Ç½¤Î¼ÂÁõ¤ò¹Ô¤¤¤Þ¤¹¡£
C# System ¤Îµ¡Ç½¤òÍøÍѤ·¤Þ¤¹¤Î¤Ç¡¢using ¤Ë System ¤ÎÀë¸À¤òÄɲ䷤Ƥ¤¤Þ¤¹¡£


GameData.cs

<= ¥¯¥ê¥Ã¥¯¤¹¤ë¤È³«¤­¤Þ¤¹


¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¥»¡¼¥Ö¤ò¹Ô¤¤¤Þ¤¹¡£


¡ãString.Split ¥á¥½¥Ã¥É¤È StringSplitOptions Îóµó·¿¡ä


¡¡Split ¥á¥½¥Ã¥É¤Ï String ¥¯¥é¥¹¤¬»ý¤Äµ¡Ç½¤Î£±¤Ä¤Ç¤¹¡£ÍøÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢using System ¤ÎÀë¸À¤¬É¬Íפˤʤê¤Þ¤¹¡£
Split ¥á¥½¥Ã¥É¤Ë¤Ï°ú¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É¤¬Â¿¤¯¤¢¤ê¤Þ¤¹¤¬¡¢º£²ó¤Ï¡¢Split(String[], StringSplitOptions) ¤Î½ñ¼°¤Î°ú¿ô¤òÍøÍѤ·¤Æ¤¤¤Þ¤¹¡£


¡ã»²¹Í¥µ¥¤¥È¡ä
MicroSoft
String.Split ¥á¥½¥Ã¥É
https://docs.microsoft.com/ja-jp/dotnet/api/system...


¡¡º£²ó¤Î¾ì¹ç¤Î Split ¥á¥½¥Ã¥É¤Ï¡¢Âè1°ú¿ô¤Ë»ØÄꤷ¤¿Ê¸»úÎó¤Ç¡¢ÂоݤȤʤëʸ»úÎóÆâ¤ò¶èÀڤäơ¢£±¤Ä¤Îʸ»úÎó¤òʬ³ä¤¹¤ë¾ì¹ç¤Ë»ÈÍѤ·¤Þ¤¹¡£

  // ¥«¥ó¥Þ¤Î°ÌÃ֤ǶèÀڤäơ¢Ê¸»úÎó¤ÎÇÛÎó¤òºîÀ®¡£¤½¤ÎºÝ¡¢ºÇ¸å¤Ë¤Ç¤­¤ë¶õÇò¤Îʸ»úÎó¤òºï½ü
  string[] strArray = cleatStageNoListString.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

¡¡º£²ó¤Î¾ì¹ç¤Ç¤¢¤ì¤Ð¡¢cleatStageNoListString ¤¬Ê¬³ä¤ÎÂоݤȤʤëʸ»úÎó¤Ç¤¹¡£
¤³¤Îʸ»úÎó¤òÀèƬ¤«¤éÄ´ºº¤·¤Æ¤¤¤­¡¢Âè1°ú¿ô¤Ç»ØÄꤷ¤Æ¤¤¤ë , (¥«¥ó¥Þ)¤ÎÉôʬ¤Ç¶èÀڤꡢʬ³ä¤·¤Þ¤¹¡£Ê¬³ä¸å¡¢¤½¤ì¤òÇÛÎó¤È¤·¤Æ strArray ÊÑ¿ô¤ËÂåÆþ¤·¤Æ¤¤¤Þ¤¹¡£

¡¡Î㤨¤Ð¡¢cleatStageNoListString ÊÑ¿ô¤ÎÃͤ¬ {0, 1, 2} ¤Ç¤¢¤ë¤Ê¤é¤Ð¡¢¤³¤ì¤ò¥«¥ó¥Þ¤Î°ÌÃ֤ǶèÀڤꡢ£³¤Ä¤Îʸ»úÎó¤Ëʬ³ä¤·¤Æ¤¤¤Þ¤¹¡£
¤½¤ì¤òÇÛÎó¤È¤·¤ÆÂåÆþ¤·¤Æ¤¤¤Þ¤¹¡£



¡¡StringSplitOptions Îóµó·¿¤Ï¡¢Split ¥á¥½¥Ã¥É¤Ë»ØÄê¤Ç¤­¤ë¥ª¥×¥·¥ç¥óµ¡Ç½¤Ç¤¹¡£º£²ó¤Î°ú¿ô¤Î¾ì¹ç¤Ï¡¢Âè2°ú¿ô¤È¤·¤ÆÀßÄê¤Ç¤­¤Þ¤¹¡£

¡¡StringSplitOptions Îóµó·¿¤Ë¤Ï£³¼ïÎà¤ÎÎóµó»Ò¤¬¤¢¤ê¡¢¤³¤Îµ¡Ç½¤ò³èÍѤ¹¤ë¤È¡¢ÊÖ¤µ¤ì¤¿ÇÛÎ󤫤é¤Î¶õ¤ÎÉôʬʸ»úÎó¤ò¾Êά¤¹¤ë¤«¤É¤¦¤«¡¢
¤Þ¤¿¤ÏÉôʬʸ»úÎ󤫤é¶õÇò¤ò¥È¥ê¥ß¥ó¥°¤¹¤ë¤«¤É¤¦¤«¤Ê¤É¤Î¥ª¥×¥·¥ç¥ó¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

¡¡º£²ó¤Ï RemoveEmptyEntries ¤ÎÎóµó»Ò¤ò»ØÄꤷ¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢Ê¸»úÎó¤òʬ³ä¤·¤Æ¤¤¤Ã¤Æ¶õÇò¤Î¾ðÊ󤬺îÀ®¤µ¤ì¤¿¾ì¹ç¡¢¤½¤ì¤ò¾Êά(¶õÇò¤òºï½ü)¤·¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢ÇÛÎó¤ÎÍ×ÁǤˤ϶õÇò¤Î¾ðÊó¤¬ÂåÆþ¤µ¤ì¤Ê¤¤¤è¤¦¤ËÀ©¸æ¤·¤Æ¤¤¤Þ¤¹¡£


¡ã»²¹Í¥µ¥¤¥È¡ä
MicroSoft
StringSplitOptions Îóµó·¿
https://docs.microsoft.com/ja-jp/dotnet/api/system...


¥²¡¼¥à¤ò¼Â¹Ô¤·¤ÆÆ°ºî¤ò³Îǧ¤¹¤ë


¡¡¥Ç¥Ð¥Ã¥°¤ÎÊýË¡¤Ï¡¢Á°²ó¤Î¥¯¥ê¥¢¥Ý¥¤¥ó¥È¤Î¾ì¹ç¤ÈƱ¤¸¤Ç¤¹¡£
GameData ¥¯¥é¥¹¤Î Awake ¥á¥½¥Ã¥ÉÆâ¤Ë¥»¡¼¥Ö¡¦¥í¡¼¥É¤Î¥á¥½¥Ã¥É¤òµ­½Ò¤·¤Æ¡¢¥Ç¥Ð¥Ã¥°¤ò¹Ô¤¤¤Þ¤¹¡£
¤½¤ÎÅÔÅÙ¡¢clearStageNoList ¤ÎÃͤòÊѹ¹¤·¤¿¤ê¤·¤Ê¤¬¤é¡¢³Îǧ¤ò·«¤êÊÖ¤·¤Æ½èÍý¤ËÌäÂ꤬¤Ê¤¤¤«¤ò¥Á¥§¥Ã¥¯¤·¤Þ¤¹¡£

¡¡¼«Ê¬¤Ç¹Í¤¨¤Æ¥Ç¥Ð¥Ã¥°¤ËÄ©À路¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£


¡ã¹Í¤¨¤è¤¦¡ª¡ä¡¡¥»¡¼¥Ö¤È¥í¡¼¥É¤¹¤ë¥¿¥¤¥ß¥ó¥°¤ò·è¤á¤Æ¡¢½èÍý¤Î¼ÂÁõ¤ËÄ©À魯¤ë


¡¡List ¤Î¥»¡¼¥Ö¤È¥í¡¼¥É¤Î½èÍý¤Î¥Ç¥Ð¥Ã¥°¤¬Ìµ»ö¤Ë½ªÎ»¤·¤¿¤é¡¢¼¡¤Ï¡¢¤É¤Î¥¿¥¤¥ß¥ó¥°¤Ç¥»¡¼¥Ö¤È¥í¡¼¥É¤ò¹Ô¤¦¤Î¤«¤ò¹Í¤¨¤Æ¡¢
¤½¤ÎÉôʬ¤Ë¥»¡¼¥Ö¤È¥í¡¼¥É¤Î¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë½èÍý¤ò¼ÂÁõ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£¥í¡¼¥É¤Ë¤Ä¤¤¤Æ¤Ï¡¢Á°²ó¤Î¥¯¥ê¥¢¥Ý¥¤¥ó¥È¤ÈƱ¤¸¤Ç
¥²¡¼¥à³«»Ï»þ¤Ë£±²ó¤À¤±¼Â¹Ô¤¹¤ì¤Ð¤¤¤¤¤Î¤Ç¡¢¥»¡¼¥Ö¤¹¤ëÉôʬ¤ò¹Í¤¨¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£


¡ã±þÍÑ¡ä¡¡¡¼GameData ¥¯¥é¥¹¤Î¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¡¼


¡¡GameData ¥¯¥é¥¹¤Î SaveClearStageNoList ¥á¥½¥Ã¥É¤È LoadClearStageNoList ¥á¥½¥Ã¥É¤Î½èÍý¤ò
Ìá¤êÃÍ¤È Linq ¤ËÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¥á¥½¥Ã¥É¤ò³èÍѤ·¤Æ¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤ò¹Ô¤¤¤Þ¤¹¡£

¡¡ºÇ½é¤Ë SaveClearStageNoList ¥á¥½¥Ã¥É¤«¤é¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤ò¹Ô¤¤¤Þ¤¹¡£
Ìá¤êÃͤò»ý¤Ä ConvertListToString ¥á¥½¥Ã¥É¤ò¿·¤·¤¯ºîÀ®¤·¡¢¤½¤Î¿·¤·¤¤¥á¥½¥Ã¥ÉÆâ¤Ç¡¢
¤¤¤Þ¤Þ¤Ç SaveClearStageNoList ¥á¥½¥Ã¥É¤Ë¤ª¤¤¤Æ½èÍý¤·¤Æ¤¤¤¿ List<int> ·¿¤ò string ·¿¤ËÊÑ´¹¤¹¤ë½èÍý¤ÎÆâÍƤò
Linq ¤ËÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¥á¥½¥Ã¥É¤òÍøÍѤ·¤Æ¼ÂÁõ¤·¤Æ¤¤¤Þ¤¹¡£


¡ãSaveClearStageNoList ¥á¥½¥Ã¥É¤Î¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¡ä

using System.Linq;    //  <=  ¿·¤·¤¯Àë¸À¤òÄɲä·¤Þ¤¹


¡¡¡¡¡ÊÃæά¡Ë


    /// <summary>
    /// clearStageNoList ¤ÎÃͤò¥»¡¼¥Ö
    /// </summary>
    public void SaveClearStageNoList () {


////*¡¡¤³¤³¤«¤é¥³¥á¥ó¥È¥¢¥¦¥È¡¡*////


        // ¿·¤·¤¯ºîÀ®¤¹¤ëʸ»úÎó
        //string clearStageNoListString = "";

        // ·ÀÌó¤·¤¿¥­¥ã¥é¤Î List ¤ò¥«¥ó¥Þ¶èÀÚ¤ê¤Î£±¹Ô¤Îʸ»úÎó¤Ë¤¹¤ë
        //for (int i = 0; i < clearStageNoList.Count; i++) {
        //    clearStageNoListString += clearStageNoList[i].ToString() + ",";
        //}

        // ʸ»úÎó¤ò¥»¥Ã¥È¤·¤Æ¥»¡¼¥Ö
        //PlayerPrefs.SetString(CLEAR_STAGE_NO_KEY, clearStageNoListString);


////*¡¡¤³¤³¤Þ¤Ç¡¡*////


////*¡¡Âå¤ï¤ê¤Ë¿·¤·¤¤½èÍý¤òÄɲá¡*////


        // ¥³¥á¥ó¥È¥¢¥¦¥È¤·¤¿¾åµ­¤Î½èÍý¤ò£±¹Ô¤Çµ­½Ò¤·¤Þ¤¹¡£
        // SetString ¥á¥½¥Ã¥É¤ÎÂè2°ú¿ôÆâ¤Ç¤Ï ConvertListToString ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¡¢string ·¿¤ÎÌá¤êÃͤò¼õ¤±¼è¤ê¡¢¤½¤ì¤òÂè2°ú¿ô¤È¤·¤ÆÀßÄꤷ¤Æ¤¤¤Þ¤¹
        PlayerPrefs.SetString(CLEAR_STAGE_NO_KEY, ConvertListToString(clearStageNoList));


////*¡¡¤³¤³¤Þ¤Ç¡¡*////


        PlayerPrefs.Save();
    }


////*¡¡¿·¤·¤¤¥á¥½¥Ã¥É¤òÄɲá¡*////


    /// <summary>
    /// int ·¿¤Î List ¤ÎÃͤò¥«¥ó¥Þ¶èÀÚ¤ê¤Î1¹Ô¤Î string ·¿¤ËÊÑ´¹
    /// </summary>
    /// <param name="listData"></param>
    /// <returns></returns>
    public string ConvertListToString(List<int> listData) {

¡¡¡¡¡¡¡¡// ¤³¤Î½èÍý¤Ï Linq ¤Îµ¡Ç½¤òÍøÍѤ·¤Æµ­½Ò¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¡¡¡¡¡¡¡¡// ¤³¤Î½èÍý¤Ï¡¢GameData ¥¯¥é¥¹¤Î SaveCleaeStageNoList ¥á¥½¥Ã¥ÉÆâ¤Î½èÍý¤Î¡¢List<int> ·¿¤Î¾ðÊó¤ò string ·¿(£±¹Ô¤Î¥«¥ó¥Þ¶èÀÚ¤ê¤Îʸ»úÎó)¤Ë¤¹¤ë½èÍý¤ÈƱ¤¸¤â¤Î¤Ç¤¹
        return listData.Select(x => x.ToString()).Aggregate((a, b) => a + "," + b);
    }


////*¡¡¤³¤³¤Þ¤Ç¡¡*////





¡¡Â³¤¤¤Æ¡¢LoadClearStageNoList ¥á¥½¥Ã¥É¤Î¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤ò¹Ô¤¤¤Þ¤¹¡£
¸½ºß¤ÏÈó¾ï¤ËŤ¤½èÍý¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢¤³¤Á¤é¤â¡¢Ìá¤êÃͤò»ý¤Ä ConvertStringToList ¥á¥½¥Ã¥É¤ò¿·¤·¤¯ºîÀ®¤·¤Æ¡¢
Linq ¤ÇÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¥á¥½¥Ã¥É¤ò³èÍѤ¹¤ë¤³¤È¤Ë¤è¤ê¡¢¥¹¥Þ¡¼¥È¤Ê½ñ¼°¤Ë½ñ¤­´¹¤¨¤ë¤³¤È¤¬²Äǽ¤Ç¤¹¡£


¡ãLoadClearStageNoList ¥á¥½¥Ã¥É¤Î¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¡ä
    /// <summary>
    /// clearStageNoList ¤ÎÃͤò¥í¡¼¥É
    /// </summary>
    public void LoadClearStageNoList () {


////*¡¡¤³¤³¤«¤é¥³¥á¥ó¥È¥¢¥¦¥È¡¡*////


        // ʸ»úÎó¤È¤·¤Æ¥í¡¼¥É
        //string clearStageNoListString = PlayerPrefs.GetString(CLEAR_STAGE_NO_KEY, "");

        // ¥í¡¼¥É¤·¤¿Ê¸»úÎ󤬤¢¤ë¾ì¹ç
        //if (!string.IsNullOrEmpty(clearStageNoListString)) {

            // ¥«¥ó¥Þ¤Î°ÌÃ֤ǶèÀڤäơ¢Ê¸»úÎó¤ÎÇÛÎó¤òºîÀ®¡£¤½¤ÎºÝ¡¢ºÇ¸å¤Ë¤Ç¤­¤ë¶õÇò¤Îʸ»úÎó¤òºï½ü
        //    string[] strArray = clearStageNoListString.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

        //    Debug.Log(strArray.Length);

            // ÇÛÎó¤Î¿ô¤À¤±·ÀÌó¤·¤¿¥­¥ã¥é¤Î¾ðÊ󤬤¢¤ë¤Î¤Ç
        //    for (int i = 0; i < strArray.Length; i++) {
                Debug.Log(strArray[i]);

                // ÇÛÎó¤Îʸ»úÎó¤ÎÃͤò int ·¿¤ËÊÑ´¹¤·¤Æ List ¤ËÄɲ䷤ơ¢·ÀÌó¥­¥ã¥é¤Î List ¤òÉü¸µ
        //        clearStageNoList.Add(int.Parse(strArray[i]));
        //    }
        //}


////*¡¡¤³¤³¤Þ¤Ç¡¡*////


////*¡¡Âå¤ï¤ê¤Ë¿·¤·¤¤½èÍý¤òÄɲá¡*////


        // ¥³¥á¥ó¥È¥¢¥¦¥È¤·¤¿¾åµ­¤Î½èÍý¤ò£±¹Ô¤Çµ­½Ò¤·¤Þ¤¹¡£
        // ConvertStringToList ¥á¥½¥Ã¥É¤Î°ú¿ô¤È¤·¤Æ GetString ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¡¢List<int> ·¿¤ÎÌá¤êÃͤò¼õ¤±¼è¤ê¡¢¤½¤ì¤ò clearStageNoList ¤ËÀßÄꤷ¤Æ¤¤¤Þ¤¹
        clearStageNoList = ConvertStringToList(PlayerPrefs.GetString(CLEAR_STAGE_NO_KEY, ""));


////*¡¡¤³¤³¤Þ¤Ç¡¡*////


    }


////*¡¡¿·¤·¤¤¥á¥½¥Ã¥É¤òÄɲá¡*////


    /// <summary>
    /// ¥«¥ó¥Þ¶èÀÚ¤ê¤Ë¤Ê¤Ã¤Æ¤¤¤ë1¹Ô¤Î string ·¿¤ÎÃͤò int ·¿¤Î List ¤ËÊÑ´¹
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public List<int> ConvertStringToList(string str) {

¡¡¡¡¡¡¡¡// ¤³¤Î½èÍý¤Ï Linq ¤Îµ¡Ç½¤òÍøÍѤ·¤Æµ­½Ò¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
        // GameData ¥¯¥é¥¹¤Î LoadCleaeStageNoList ¥á¥½¥Ã¥ÉÆâ¤Î½èÍý¤Î¡¢string ·¿(£±¹Ô¤Î¥«¥ó¥Þ¶èÀÚ¤ê¤Îʸ»úÎó)¤ò List<int> ·¿¤Ë¤¹¤ë½èÍý¤ÈƱ¤¸¤Ç¤¹
        return str.Split(',').ToList().ConvertAll(x => int.Parse(x));
    }


////*¡¡¤³¤³¤Þ¤Ç¡¡*////




¡ãLinq¤Îµ¡Ç½¤Î¼ÂÁõÎã­¢¡¡¡ÁAggregate ¥á¥½¥Ã¥É¡¢ToList ¥á¥½¥Ã¥É¡ä


¡¡¿·¤·¤¯¼ÂÁõ¤·¤Æ¤¤¤ë Linq ¤Î¥á¥½¥Ã¥É¤Ë¤Ä¤¤¤Æ½çÈÖ¤ËÀâÌÀ¤ò¹Ô¤¤¤Þ¤¹¡£
£±¡¥Aggregate ¥á¥½¥Ã¥É

¡¡¥¢¥°¥ê¥²¡¼¥È¤ÈÆɤߤޤ¹¡£±Ññ¸ì¤È¤·¤Æ¤Ï¡¢½¸·×¤È¤¤¤¦°ÕÌ£¤ò»ý¤Á¤Þ¤¹¡£

  listData.Select(x => x.ToString()).Aggregate((a, b) => a + "," + b);

¡¡Select ¥á¥½¥Ã¥É¤òÍøÍѤ·¤Æ int ·¿¤Î¾ðÊó¤¬ string ·¿¤Ë·¿ÊÑ´¹¤µ¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢¤½¤Î string ·¿¤Î¾ðÊó¤ËÂФ·¤Æ¡¢Aggregate ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
¤³¤Î¥á¥½¥Ã¥É¤Ï¡¢ºîÍѤ¹¤ë½èÍý¤Î·¿¤Î¾ðÊó¤òÌá¤êÃͤȤ·¤Æ»ý¤Á¤Þ¤¹¡£¤½¤Î¤¿¤áº£²ó¤Ç¤¢¤ì¤Ð¡¢string ·¿¤ÎÌá¤êÃͤò»ý¤Ä½èÍý¤Ë¤Ê¤ê¤Þ¤¹¡£

¡¡Aggregate ¥á¥½¥Ã¥É¤Î°ú¿ô¤Ï¥é¥à¥À¼°¤Ë¤è¤ëµ­½Ò¤ò¹Ô¤¦·è¤Þ¤ê¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
Âè1°ú¿ô¤Ï a ÊÑ¿ô¤òÀë¸À¤·¤Æ¤¤¤ëÉôʬ¤Ç¤¢¤ê¡¢¤³¤³¤Ë¤Ï½¸·×·ë²Ì¤¬ÂåÆþ¤µ¤ì¤Þ¤¹¡£
Âè2°ú¿ô¤Ï b ÊÑ¿ô¤òÀë¸À¤·¤Æ¤¤¤ëÉôʬ¤Ç¤¢¤ê¡¢¤³¤³¤Ë¤Ï Select ¥á¥½¥Ã¥É¤Î½èÍý·ë²Ì¤Ç¤¢¤ë string ·¿¤Î List ¤Î¾ðÊó¤¬Í×ÁǤȤ·¤ÆÂåÆþ¤µ¤ì¤Æ¡¢£±¤Ä¤º¤Ä½çÈ֤˽èÍý¤¬¹Ô¤ï¤ì¤Þ¤¹¡£

¡¡½èÍý¤ÎÆâÍƤϡ¢=> ¤Î±¦Â¦¤ÎÉôʬ¤ËÀßÄꤷ¤Þ¤¹¡£º£²ó¤Ï a + "," + b ¤ÈÀßÄꤷ¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢List ¤ÎºÇ½é¤Îʸ»úÎó¤Ë , (¥«¥ó¥Þ)¤ò²Ã¤¨¤Æ¤«¤é¡¢List ¤Î¼¡¤Îʸ»úÎó¤ò­¤·¤Þ¤¹¡£
¤³¤ì¤ò¡¢List ¤ÎÍ×ÁǤ¬Ìµ¤¯¤Ê¤ë¤Þ¤Ç·«¤êÊÖ¤·¡¢ºÇ½ªÅª¤Ë string ·¿¤Î¾ðÊó¤¬ÃͤȤ·¤ÆºîÀ®¤µ¤ì¤Þ¤¹¡£

¡¡Î㤨¤Ð¡¢listData ÊÑ¿ô¤ÎÃͤ¬ {0, 2, 4} ¤Ç¤¢¤Ã¤¿¤È¤·¤¿¾ì¹ç¡¢ºÇ½é¤Ë¡¢Select ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Æ¡¢¤³¤Î£³¤Ä¤ÎÃÍ¤Ï int ·¿¤«¤é string ·¿¤Ë·¿ÊÑ´¹¤µ¤ì¤Þ¤¹¡£
¼¡¤Ë Aggregate ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Æ¡¢string ·¿¤Î List ¤ÎÍ×ÁǤ¬£±¤Ä¤º½àÈǤ˼è¤ê½Ð¤µ¤ì¤Þ¤¹¡£

¡¡a + "," + b ¤ÎÉôʬ¤Ë¼Â¿ôÃͤòÅö¤Æ¤Ï¤á¤Æ¤ß¤ë¤È

 a + "," + b

 0,2       (a = 0   b = 2)
 0,2,4     (a = 0,2   b = 4)

¡¡¤È¤¤¤¦½èÍý¤Ë¤Ê¤ê¤Þ¤¹¡£¤è¤Ã¤Æ¡¢Aggregate ¥á¥½¥Ã¥É¤Î½èÍý¤Î·ë²Ì¡¢List ¤ÎÍ×ÁǤ¬£±¤Ä¤Îʸ»úÎó¤ÎÃͤˤʤê¤Þ¤¹¡£


¡ã»²¹Í¥µ¥¤¥È¡ä
MicroSoft
Enumerable.Aggregate ¥á¥½¥Ã¥É
https://docs.microsoft.com/ja-jp/dotnet/api/system...
.NET Column ÍÍ
¡ÚC#¤ÈLINQ¡ÛAggregate¥á¥½¥Ã¥É¤ò»È¤Ã¤Æ¥Ç¡¼¥¿¤Î½¸·×¤ò¤¹¤ëÊýË¡
https://www.fenet.jp/dotnet/column/language/2048/
¥²¡¼¥Þ¡¼¤È¤­¤É¤­¥¨¥ó¥¸¥Ë¥¢ ÍÍ
¡ÚC#¡Û¡ÚLINQ¡ÛAggregate¥á¥½¥Ã¥É¤Î»È¤¤Êý¤ò²òÀ⤷¤Þ¤¹
https://www.tairax.com/entry/Csharp/LINQ-Aggregate


£²¡¥ToList ¥á¥½¥Ã¥É

¡¡ÇÛÎó¤ä¡¢Linq ¤Î Select ¥á¥½¥Ã¥É¡¢Where ¥á¥½¥Ã¥É¤Î·ë²Ì¤ò List ¤Î¥¤¥ó¥¹¥¿¥ó¥¹(¼ÂÂÎ)¤È¤·¤ÆºîÀ®¤·¤Þ¤¹¡£
Select ¥á¥½¥Ã¥É¤Ê¤É¤ÎÌá¤êÃͤǤ¢¤ë IEnumerable·¿¤ÎÃͤÏÃê½Ð¤·¤¿¤À¤±¤Ç List ¤Î¾õÂ֤ˤϤʤäƤ¤¤Þ¤»¤ó¤Î¤Ç¡¢Ãê½Ð¤·¤¿¾ðÊó¤ò List ¤È¤·¤ÆÍøÍѤ·¤¿¤¤¾ì¹ç¤Ë¤Ï
¤³¤Î ToList ¥á¥½¥Ã¥É¤Î½èÍý¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ë¤è¤ê List ¤È¤·¤ÆÃͤ¬ºîÀ®¤µ¤ì¤Þ¤¹¡£


¡ã»²¹Í¥µ¥¤¥È¡ä
MicroSoft
Enumerable.ToList<TSource>(IEnumerable<TSource>) ¥á¥½¥Ã¥É
https://docs.microsoft.com/ja-jp/dotnet/api/system...
Ķ½é¿´¼Ô¸þ¤±¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç ÍÍ
LINQ¤Î¼çÍץ᥽¥Ã¥É°ìÍ÷
https://programming.pc-note.net/csharp/linq_method...
¥ä¥¹¥Î¡¼¥È¤Ïº£Æü¤â¹Í¤¨¤ë ÍÍ
[C# LINQ] ÇÛÎó¤äSelect¡¢Where¤·¤¿·ë²Ì¤ò¥ê¥¹¥È¤ËÊÑ´¹¤¹¤ë
https://yaspage.com/prog/csharp/cs-linq-tolist/


¡ãList¤Î»È¤¤Êý­£¡¡¡¼ConvertAll ¥á¥½¥Ã¥É¡¼¡ä


¡¡List ¤Î»ý¤Ä¥á¥½¥Ã¥É¤Î£±¤Ä¤Ç¤¹¡£Array(ÇÛÎó)¤Ë¤âƱ̾¡¦Æ±µ¡Ç½¤Î¥á¥½¥Ã¥É¤¬¤¢¤ê¤Þ¤¹¡£

¡¡ConvertAll ¥á¥½¥Ã¥É¤òÍøÍѤ¹¤ë¤È¡¢°ú¿ô¤Ë»ØÄꤷ¤¿Í×ÁǤò¤¹¤Ù¤ÆÊ̤η¿¤ËÊÑ´¹¡Ê¥­¥ã¥¹¥È¡Ë½èÍý¤ò¹Ô¤¦¤³¤È¤¬½ÐÍè¤Þ¤¹¡£

  str.Split(',').ToList().ConvertAll(x => int.Parse(x));

¡¡x ÊÑ¿ô¤ÎÉôʬ¤Ë¤Ï List ¤ÎÍ×ÁǤ¬½çÈÖ¤ËÂåÆþ¤µ¤ì¤Þ¤¹¡£
º£²ó¤Î¼ÂÁõÎã¤Ç¤Ï¡¢string ·¿¤Î List ¤Î¤¹¤Ù¤Æ¤ÎÍ×ÁǤò ConvertAll ¥á¥½¥Ã¥É¤òÍøÍѤ·¡¢ int.Paruse ¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æ int ·¿¤Ë·¿ÊÑ´¹¤¹¤ë½èÍý¤ò¼Â¹Ô¤·¤Æ¤¤¤Þ¤¹¡£
¤³¤ì¤Ë¤è¤ê¡¢Ìá¤êÃͤη¿¤Ç¤¢¤ë List<int> ·¿¤ÎÃͤ¬ºîÀ®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

    public List<int> ConvertStringToList(string str) {
        return str.Split(',').ToList().ConvertAll(x => int.Parse(x));   // <=¡¡½èÍý¤¬ºÇ¸å¤Þ¤Ç´°Î»¤¹¤ë¤³¤È¤ÇÌá¤êÃͤη¿¤Ç¤¢¤ë List<int> ·¿¤ÎÃͤˤʤë
    }


¡ã»²¹Í¥µ¥¤¥È¡ä
MicroSoft
List<T>.ConvertAll<TOutput>(Converter<T,TOutput>) ¥á¥½¥Ã¥É
https://docs.microsoft.com/ja-jp/dotnet/api/system...

ConvertAll¥á¥½¥Ã¥É¤ò»È¤Ã¤Æʸ»úÎ󷿤ÎList¤«¤é¿ôÃÍ·¿¤ÎList¤ËÊÑ´¹¤¹¤ë
https://smdn.jp/programming/dotnet-samplecodes/col...


¥²¡¼¥à¤ò¼Â¹Ô¤·¤ÆÆ°ºî¤ò³Îǧ¤¹¤ë


¡¡¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤ò¹Ô¤Ã¤¿¤é¡¢¤¤¤Þ¤Þ¤Ç¤ÈƱ¤¸¤è¤¦¤Ë½èÍý¤¬Æ°¤¯¤«¤É¤¦¤«¤ò³Îǧ¤·¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£




¡¡°Ê¾å¤Ç¤³¤Î¼ê½ç¤Ï½ªÎ»¤Ç¤¹¡£

¡¡¼¡¤Ï¡¡È¯Å¸£²£³¡¡¡¼¥»¡¼¥Ö¡¦¥í¡¼¥Éµ¡Ç½¤Î¼ÂÁõ­£¡Ý¡¡¤Ç¤¹¡£

¥³¥á¥ó¥È¤ò¤«¤¯


¡Öhttp://¡×¤ò´Þ¤àÅê¹Æ¤Ï¶Ø»ß¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

ÍøÍѵ¬Ìó¤ò¤´³Îǧ¤Î¤¦¤¨¤´µ­Æþ²¼¤µ¤¤

Menu



´ðÁÃ

µ»½Ñ/Ãμ±(¼ÂÁõÎã)

3D¥¢¥¯¥·¥ç¥ó¥²¡¼¥à

2D¤ª¤Ï¤¸¤­¥²¡¼¥à(ȯŸÊÔ)

2D¶¯À©²£¥¹¥¯¥í¡¼¥ë¥¢¥¯¥·¥ç¥ó(ȯŸÊÔ)

2D¥¿¥Ã¥×¥·¥å¡¼¥Æ¥£¥ó¥°(³ÈÄ¥ÊÔ)

¥ì¡¼¥¹¥²¡¼¥à(È´¿è)

2DÊüÃÖ¥²¡¼¥à(ȯŸÊÔ)

3D¥ì¡¼¥ë¥¬¥ó¥·¥å¡¼¥Æ¥£¥ó¥°(±þÍÑÊÔ)

3Dæ½Ð¥²¡¼¥à(È´¿è)

2D¥ê¥¢¥ë¥¿¥¤¥à¥¹¥È¥é¥Æ¥¸¡¼

3D¥¿¥Ã¥×¥¢¥¯¥·¥ç¥ó(NavMeshAgent »ÈÍÑ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥«¥¨¥ë¤Î°Ù¤Ë¡Á¡¢¥Ü¥³¥¹¥«¥¦¥©¡¼¥ºÉ÷)

VideoPlayer ¥¤¥Ù¥ó¥ÈϢư¤Î¼ÂÁõÎã

VideoPlayer ¥ê¥¹¥ÈÆ⤫¤é¥à¡¼¥Ó¡¼ºÆÀ¸¤Î¼ÂÁõÎã(ȯŸ)

AR ²èÁüÉÕ¤­¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¤Î¼ÂÁõÎã

AR ¥ê¥¹¥ÈÆ⤫¤éÀ¸À®¤Î¼ÂÁõÎã(ȯŸ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥µ¥Ð¥¤¥Ð¡¼É÷)

private



¤³¤Î¥µ¥¤¥ÈÆâ¤ÎºîÉʤϥæ¥Ë¥Æ¥£¤Á¤ã¤ó¥é¥¤¥»¥ó¥¹¾ò¹à¤Î¸µ¤ËÄ󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£

´ÉÍý¿Í/Éû´ÉÍý¿Í¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹