iLMS知識社群歷程檔登入
位置: 黃國哲 > Unity
1100830 列表List範例
by 黃國哲 2021-08-30 22:19:08, 回應(0), 人氣(387)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class list : MonoBehaviour
{
    public List<string> dataList ;
    // Start is called before the first frame update
    void Start()
    {
      dataList.Add("0 我是封面");
      dataList.Add ("1 我是封面你");
      dataList.Add ("2 我是封面他");
      dataList.Add ("3 我是封面她");
      dataList.Add ("4 我是封面你她");

    foreach (var page in dataList)
    {    
         Debug.Log(page);
    }

    foreach (var page in dataList)
    {
        if (page.Contains("你"))
            {
                Debug.Log(page);
            }
    }
      
    }

    
}


執行後會看到Console裡面出現文字
一組是全部顯示,另一組是只顯示有"你"的文字
回應