블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28

Category

Recent Post

Recent Comment

Archive

2009. 8. 12. 16:18 .Net Project/.Net 3.5 Sp1
반응형




using System;

public class 메서드
{

    public static void Main()
    {

        //input
        int a = 10;
        int b = 20;
        int c; //초기화 하지 않음 -> 어차피 Test에 의해서 초기화 된다면..

        //Test
        Test(a, ref b, out c); //값만 전달
        Console.WriteLine("메인 :a:{0}, b:{1}, c:{2}", a,b,c);

        //TestParms,//단일
        TestParams(10); //값 설정
        int[] data = { 10, 20 }; TestParams(data); //배열 설정
       //참조결정(가장 많이 사용방식) --> 호출과 동시에 바로 전달  
        TestParams(new int[] { 10, 20, 30 }); 
        //가변 : 콤마 ,는 원하는 만큼 찍어서 전송 가능
        TestParams(10, 20);
        TestParams(10, 20, 30);
        TestParams(10, 20, 30, 40);
    }

    public static void Test(int a, ref int b, out int c)
    {
        a = 100;
        b = 200;
        c = a + b; //c를 할당
        //Console.WriteLine("a : {0}",a);
        //Console.WriteLine("b : {0}",b);
        //Console.WriteLine("c : {0}",c);
        Console.WriteLine("테스트 :a:{0}, b:{1}, c:{2}", a, b, c);

    }
    public static void TestParams(params int[] arr)
    {
        foreach (var item in arr)
        {
            Console.WriteLine("{0}",item);
           
        }

    }  
}

반응형

'.Net Project > .Net 3.5 Sp1' 카테고리의 다른 글

59장 속성(Property)  (0) 2009.08.12
58장 메서드 오버로드  (0) 2009.08.12
56장 JavaScript Access(자바접근)  (0) 2009.08.11
55장 DropDownList  (0) 2009.08.11
54장 Form관련 Ex-2  (0) 2009.08.11
posted by Magic_kit