1. 程式人生 > >C# 清空陣列Array.Clear

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