C# 清空数组Array.Clear

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ClearArrayText : MonoBehaviour {

    // Use this for initialization
    void Start () 
    {
        int[] intArray = new int[] { 1, 5, 9, 4 };
        Array.Clear(intArray, 0, intArray.Length);//清空第0到第intArray.Length个索引的元素.(包括第0个,不包括第intArray.Length个)
        foreach (var item in intArray)
        {
            Debug.Log(item);
        }
    }
}

 

posted @ 2018-10-19 17:40  朋丶Peng  阅读(12248)  评论(0编辑  收藏  举报