C#可变参数params

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

public class TestParams:MonoBehaviour{
        
        private void Start(){
            test(1,2,3,4);
            test(1,4);
            
            int[] list= { 1, 2, 3, 4, 5, 6 };
            test(list);
        }
        
        private void test(params int[] list){
            
        }
        
}

猜你喜欢

转载自www.cnblogs.com/kingBook/p/10222306.html