C# 구문 – 가변 매개변수를 사용하는 방법을 알아보겠습니다.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static int Add(params int() values)
        {
            int result = 0;
            for (int i = 0; i < values.Length; i++)
            {
                result = result + values(i);
            }
            return result;
        }

        private static void PrintAll(params object() values)
        {
            foreach (object item in values)
            {
                Console.Write(item);
            }
        }
        (DllImport("user32.dll"))
        static extern int MessageBeep(uint uType);

        static int TestMethod(uint type) => 0;

        static void Main(string() args)
        {
            Console.WriteLine(Add(1,2,3,4,5));
            Console.WriteLine(Add(1, 2, 3, 4, 5,6,7,8,9,10));
            PrintAll(1.05, "Result", 3);
            MessageBeep(1);
        }
    } 
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static int Add(params int() values)
        {
            int result = 0;
            for (int i = 0; i < values.Length; i++)
            {
                result = result + values(i);
            }
            return result;
        }

        private static void PrintAll(params object() values)
        {
            foreach (object item in values)
            {
                Console.Write(item);
            }
        }
        
        static void Main(string() args)
        {
            Console.WriteLine(Add(1,2,3,4,5));
            Console.WriteLine(Add(1, 2, 3, 4, 5,6,7,8,9,10));
            PrintAll(1.05, "Result", 3);

        }
    } 
}




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string() args)
        {

            int iNum = 100;

            //주소의 사용을 막았다 
            //c# 객체지향 언어에서 참조개념이 있기 때문에 
            //주소의 사용을 막아 놓았다
            unsafe
            {
                Console.WriteLine("{0:x}", (int)&iNum);
            }
            
        }
    }
}

https://slaner.55

21. 창 텍스트 가져오기

선언: C#(DllImport(“user32”)) public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); VB.NET _ Public Shared Function GetWindowText(hWnd As IntPtr, lpString As StringBuilder, nMaxCount As Integer) As Integer End Functio

slaner.tistory.com