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);
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/Peng18233754457/p/9817794.html