[C#] params : ๊ฐ€๋ณ€ ๊ธธ์ด ๋งค๊ฐœ ๋ณ€์ˆ˜

2021. 11. 3. 09:13

๋ฉ”์†Œ๋“œ์˜ ๋งค๊ฐœ ๋ณ€์ˆ˜์˜ ๊ฐœ์ˆ˜๊ฐ€ ์ •ํ•ด์ ธ์žˆ์ง€ ์•Š์„ ๋•Œ

params๋ฅผ ํ‚ค์›Œ๋“œ๋ฅผ ํ†ตํ•ด ๋ฐฐ์—ด์„ ์ด์šฉํ•˜์—ฌ ์„ ์–ธํ•œ๋‹ค.

        public static int Plus(params int[] numbers)
        {
            ...
        }

        static void Main(string[] args)
        {
            int result1 = Plus(1, 2, 3, 4, 5);
            int result2 = Plus(1, 2, 3);


        }
728x90

BELATED ARTICLES

more