// 확장메서드 : 기존 클래스의 외부에서 메서드 추가
using System;
public class Calc
{
    public int Plus(int a, int b)
    {
        return (a + b);
    }
}

public static class CalcExtension    // Calc클래스의 외부에서 Minus메서드 확장 
{
    public static int Minus(this Calc c, int a, int b) // 문법이다. static클래스에 static메서드, 첫번째 매개변수로 this, 두번째 자리에 확장할 클래스(Calc), 세번째 자리에 내가 원하는 변수명
    {
        return (a - b);
    }
}

public class 확장메서드
{
    public static void Main()
    {
        Calc c = new Calc();
        Console.WriteLine(c.Plus(3, 5)); // 8
        Console.WriteLine(c.Minus(3,5)); // -2

        string s = "확장메서드";
        Console.WriteLine("{0}", s.ShowTitle()); // ***확장메서드*** 로 출력시킴
       
        int i = -10;
        Console.WriteLine("절대값 : {0}", i.Abs()); // (메서드)확장
    }

}

// CLR에 이미 만들어져 있는 String 클래스 확장
public static class StringExtension
{
    public static string ShowTitle(this String s)
    {
        return "***" + s + "***";
    }
}

// Int32 구조체에 Abs() 메서드를 추가(확장)
public static class Int32Extension
{
    public static int Abs(this Int32 i)
    {
        return (i < 0) ? -i : i;
    }
}

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

82. IEnumerable인터페이스  (0) 2009.08.19
81. 람다식  (0) 2009.08.19
(테스트) 학점 계산 프로그램  (0) 2009.08.19
79. 초기화자(Initializer)  (0) 2009.08.18
알고리즘 - 12. 그룹(Group)  (0) 2009.08.18
Posted by holland14
:


==> 학점계산프로그램.cs



using System;
using System.Collections.Generic;

public class 학점계산프로그램
{
    public static void Main() {
        //[1] Input
        List<Score> sco = new List<Score>() {
            new Score{번호=1, 영어=90, 일어=98},
            new Score{번호=2, 영어=76, 일어=22},
            new Score{번호=3, 영어=83, 일어=68}
        };
        //[2] Process : 총점/평균/학점
        for (int i = 0; i < sco.Count; i++) {
            sco[i].총점 = sco[i].영어 + sco[i].일어;
            sco[i].평균 = sco[i].총점 / 2;
            int 학점 = Convert.ToInt32(sco[i].평균) / 10;
            switch (학점) {
                case 10:
                case 9: sco[i].학점 = 'A'; break;
                case 8: sco[i].학점 = 'B'; break;
                case 7: sco[i].학점 = 'C'; break;
                default: sco[i].학점 = 'D'; break;
            }
        }
        //[3] Output
        for (int i = 0; i < sco.Count; i++) {
            Console.WriteLine(
                "{0,8} {1,8} {2,8} {3,8} {4,8} {5}"
                , sco[i].번호, sco[i].영어, sco[i].일어
                , sco[i].총점, sco[i].평균, sco[i].학점);
        }
    }   
}




==============================================================================================




==> Score.cs




using System;

public class Score
{
    public int 번호 { get; set; }
    public int 영어 { get; set; }
    public int 일어 { get; set; }
    public int 총점 { get; set; }
    public float 평균 { get; set; }
    public char 학점 { get; set; }
}

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

81. 람다식  (0) 2009.08.19
80. 확장메서드  (0) 2009.08.19
79. 초기화자(Initializer)  (0) 2009.08.18
알고리즘 - 12. 그룹(Group)  (0) 2009.08.18
78. 특성(Attribute)  (0) 2009.08.18
Posted by holland14
:

// 초기화자(Initializer) : 개체, 컬렉션
using System;
using System.Collections.Generic;

public class ProductInfo
{
    // Name 속성
    private string _Name;
    public string Name
    {
        get { return _Name; }
        set { _Name = value; }
    }

    // Quantity 자동속성 : 3.X 특징
    public int Quantity { get; set; }

    // Method
    public void Print() { Console.WriteLine("{0} : {1}", Name, Quantity); }

    // Constructor
    public ProductInfo()
    {
        // Empty
    }

    public ProductInfo(string name, int quantity)
    {
        this.Name = name; this.Quantity = quantity;
    }
}

public class 초기화자
{
    public static void Main()
    {
        // 속성으로 초기화
        ProductInfo objProduct = new ProductInfo();
        objProduct.Name = "라디오";
        objProduct.Quantity = 100;
        objProduct.Print();

        // 개체 초기화자 : 3.X 특징
        ProductInfo pi = new ProductInfo() { Name = "TV", Quantity = 50 };
        pi.Print();

        // 생성자로 초기화
        ProductInfo pro = new ProductInfo("DVD", 30);
        pro.Print();

        // 컬렉션 초기화자 : 리스트 제네릭 클래스에 상품 정보 담기
        List<ProductInfo> lst = new List<ProductInfo>();
        lst.Add(new ProductInfo("AUDIO", 3));
        lst.Add(new ProductInfo("RADIO", 5));

        // 3.X 특징
        List<ProductInfo> pros = new List<ProductInfo>()
        {
            new ProductInfo("AUDIO", 3),
            new ProductInfo{ Name="RADIO", Quantity=5 }
        };

        // 익명형(Anonymous Type) : 3.X 특징
        ProductInfo test = new ProductInfo("컴퓨터", 100);
        // 간단한 정보라면 익명형으로 Name, Quantity를 바로 생성 가능
        var at = new { Name = "컴퓨터", Quantity = 100 };
        Console.WriteLine("{0}, {1}", at.Name, at.Quantity);
    }
}

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

80. 확장메서드  (0) 2009.08.19
(테스트) 학점 계산 프로그램  (0) 2009.08.19
알고리즘 - 12. 그룹(Group)  (0) 2009.08.18
78. 특성(Attribute)  (0) 2009.08.18
77. 형식매개변수에 대한 제약조건  (0) 2009.08.18
Posted by holland14
:

using System;
using System.Collections.Generic;
using System.Collections;
public class ProductInfo
{
    public string Name { get; set; }  // 상품명
    public int Quantity { get; set; } // 판매량
    public ProductInfo()
    {
        // Empty
    }
    public ProductInfo(string name, int quantity)
    {
        this.Name = name; this.Quantity = quantity;
    }
}
public class 그룹 {
    public static void Main() {

        //[1] Input
        List<ProductInfo> lst = new List<ProductInfo>(); // 입력데이터
        List<ProductInfo> result = new List<ProductInfo>(); // 출력데이터
        #region 콘솔로부터 데이터입력
        //ProductInfo pi; string[] temp; string btn = "n";
        //do
        //{
        //    Console.Write("데이터 입력 : ");
        //    temp = Console.ReadLine().Trim().Split(' ');
        //    pi = new ProductInfo();
        //    pi.Name = temp[0].Trim().ToUpper();
        //    pi.Quantity = Convert.ToInt32(temp[1]);
        //    lst.Add(pi); // 컬렉션에 추가
        //    Console.Write("입력(y), 종료(n) : ");
        //    btn = Console.ReadLine().ToLower(); // 소문자로 y, n
        //} while (btn == "y");
        #endregion
        #region 기본값으로 초기화
        lst.Add(new ProductInfo("RADIO", 3));
        lst.Add(new ProductInfo("TV", 1));
        lst.Add(new ProductInfo("RADIO", 2));
        lst.Add(new ProductInfo("DVD", 4));
        #endregion


        //[2] Process
        //[A] 원본
        for (int i = 0; i < lst.Count; i++) {
            Console.WriteLine("{0} {1}", lst[i].Name, lst[i].Quantity);
        }

        //[B] 정렬
        ProductInfo imsi = new ProductInfo();
        for (int i = 0; i < lst.Count - 1; i++) {
            for (int j = i + 1; j < lst.Count; j++) {
                if ( String.Compare(lst[i].Name, lst[j].Name) > 0 ) {
                    imsi = lst[i]; lst[i] = lst[j]; lst[j] = imsi;
                }   
            }
        }
        for (int i = 0; i < lst.Count; i++) {
            Console.WriteLine("{0} {1}", lst[i].Name, lst[i].Quantity);
        }

        //[C] 그룹
        #region 마지막레코드를 입력 후 계산
        //int subTotal = 0; // 소계
        //ProductInfo final = new ProductInfo();
        //final.Name = ""; final.Quantity = 0;
        //lst.Add(final); // 마지막 레코드용 빈값
        //for (int i = 0; i < lst.Count - 1; i++) // 마지막 레코드(빈) 전까지
        //{
        //    subTotal += lst[i].Quantity;
        //    if (String.Compare(lst[i].Name, lst[i + 1].Name) != 0) // 다르다면
        //    {
        //        if (lst[i].Name.Trim() != "") // 마지막 데이터가 아닐때까지
        //        {
        //            ProductInfo rlt = new ProductInfo();
        //            rlt.Name = lst[i].Name;
        //            rlt.Quantity = subTotal; // 현재까지 소계
        //            result.Add(rlt); // 한개 그룹 저장
        //            subTotal = 0;
        //        }
        //    }
        //}
        #endregion
        int subTotal = 0; // 소계
        for (int i = 0; i < lst.Count; i++)
        {
            subTotal += lst[i].Quantity;
            if ((i + 1) == lst.Count || // 단락(short circuiting)
                String.Compare(lst[i].Name, lst[i + 1].Name) != 0)
            {
                ProductInfo rlt = new ProductInfo();
                rlt.Name = lst[i].Name;
                rlt.Quantity = subTotal; // 현재까지 소계
                result.Add(rlt); // 한개 그룹 저장
                subTotal = 0;               
            }
        }


        //[3] Output
        Console.WriteLine("그룹화된 자료 출력");
        for (int i = 0; i < result.Count; i++) {
            Console.WriteLine("{0} {1}", result[i].Name, result[i].Quantity);
        }
    }   
}
// 원본 데이터가 아래와 같이 들어온다면???
// 이 데이터를 상품명으로 그룹화하자
// RADIO  5           DVD    5
// TV     6    -->    PHONE  5
// PHONE  3           RADIO  7
// RADIO  2           TV    16
// PHONE  2   
// TV    10      
// DVD    5

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

(테스트) 학점 계산 프로그램  (0) 2009.08.19
79. 초기화자(Initializer)  (0) 2009.08.18
78. 특성(Attribute)  (0) 2009.08.18
77. 형식매개변수에 대한 제약조건  (0) 2009.08.18
76. 제네릭클래스  (0) 2009.08.18
Posted by holland14
:


==> 특성.cs



using System;

public class 특성 // 모든 특성은 클래스이다. 뒤에붙는 Attribute접미사는 생략가능하다.
{
    public static void Main()
    {
        Say1();
        Say2();
    }

    /// <summary>
    /// 닷넷 1.0 버전
    /// </summary>
    [Obsolete("현재 메서드는 오래된 버전이므로, Say2()를 사용하세요.", false)] // false로 하면 실행되고 경고만 뜨지만, true로 하면 실행되지 않는다. 
    public static void Say1()
    {
        Console.WriteLine("안녕");
    }

    /// <summary>
    ///  닷넷 2.0 버전 이상
    /// </summary>
    public static void Say2()
    {
        Console.WriteLine("안녕하세요");
    }
}



==============================================================================================




==> 사용자정의특성.cs



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

namespace 사용자정의특성
{
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple=true)] // Method와 Class에 특성을 주고 다중사용 가능하게 한다.
    public class AuthorAttribute : Attribute // 작성자 정보를 담아놓을 수 있는 간단한 특성
    {
        public string name; // 이름의 정보를 담아놓을(보관) 수 있는 그릇 하나. 여기서는 필드를 public으로 선언했다.
        public AuthorAttribute(string name)
        {
            this.name = name;
        }
    }
    [AuthorAttribute("RedPlus")]
    class 사용자정의특성
    {
        static void Main(string[] args)
        {
            Say();

            ShowMetaData();
        }

        // 특성정보 읽어오기
        private static void ShowMetaData()
        {
            System.Attribute[] attrs = System.Attribute.GetCustomAttributes(typeof(사용자정의특성));
            foreach (var attr in attrs)
            {
                //if (attr is AuthorAttribute)
                //{
                //    AuthorAttribute aa =(AuthorAttribute)attr;
                //    Console.WriteLine("{0}", aa.name);
                //}
                AuthorAttribute aa = attr as AuthorAttribute;
                if (aa != null)
                {
                    Console.WriteLine("{0}", aa.name);
                }
            }
        }
        static void Say() { Console.WriteLine("안녕하세요."); }
    }
}

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

79. 초기화자(Initializer)  (0) 2009.08.18
알고리즘 - 12. 그룹(Group)  (0) 2009.08.18
77. 형식매개변수에 대한 제약조건  (0) 2009.08.18
76. 제네릭클래스  (0) 2009.08.18
75. 리스트제네릭클래스  (0) 2009.08.17
Posted by holland14
:

using System;

public class CarValue<T> where T : struct { } // 값타입
public class CarReference<T> where T : class { } // 참조타입
public class CarNew<T> where T : new() { } // Default 생성자
public class CarClass<T> where T : Hyundai { } // Hyundai에서 파생된 것(클래스)이어야 한다.
public class CarInterface<T> where T : IKs { } // IKs인터페이스형이어야 한다.

public interface IKs { }
public class Hyundai { }
public class Sonata : Hyundai, IKs { }       

public class 형식매개변수에대한제약조건
{
    public static void Main()
    {
        CarValue<int> c = new CarValue<int>(); // 값타입이므로 struct 성공
        CarReference<string> cs = new CarReference<string>(); // 참조타입이므로 class 성공
        CarNew<Hyundai> cn = new CarNew<Hyundai>(); // new() 성공
        CarClass<Sonata> cc = new CarClass<Sonata>(); // 사용자 정의 타입
        CarInterface<IKs> h = new CarInterface<IKs>(); // 인터페이스
    }

}





/* MSDN 설명

where T: struct
 형식 인수가 값 형식이어야 합니다. Nullable를 제외한 임의의 값 형식을 지정할 수 있습니다. 자세한 내용은 Nullable 형식 사용(C# 프로그래밍 가이드)을 참조하십시오.
 
where T : class
 형식 인수가 참조 형식이어야 합니다. 이는 모든 클래스, 인터페이스, 대리자 또는 배열 형식에도 적용됩니다.
 
where T : new()
 형식 인수가 매개 변수 없는 공용 생성자여야 합니다. 다른 제약 조건과 함께 사용하는 경우 new() 제약 조건은 마지막에 지정해야 합니다.
 
where T : <기본 클래스 이름>
 형식 인수가 지정된 기본 클래스이거나 지정된 기본 클래스에서 파생되어야 합니다.
 
where T : <인터페이스 이름>
 형식 인수가 지정된 인터페이스이거나 지정된 인터페이스를 구현해야 합니다. 여러 인터페이스 제약 조건을 지정할 수 있습니다. 제한하는 인터페이스는 제네릭이 될 수도 있습니다.
 
where T : U
 T에 대해 지정한 형식 인수가 U에 대해 지정한 인수이거나 이 인수에서 파생되어야 합니다. 이를 naked 형식 제약 조건이라고 합니다. 

*/
 

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

알고리즘 - 12. 그룹(Group)  (0) 2009.08.18
78. 특성(Attribute)  (0) 2009.08.18
76. 제네릭클래스  (0) 2009.08.18
75. 리스트제네릭클래스  (0) 2009.08.17
74. 예외처리  (0) 2009.08.17
Posted by holland14
:

using System;

public class 제네릭클래스
{
    public static void Main()
    {
        // 기본클래스 메서드 호출
        //Hello h = new Hello();
        //h.SayInt(1234); h.SayStr("안녕"); h.SayObj(DateTime.Now);
        // 제네릭 클래스 호출
        Hello<int> hi = new Hello<int>(); hi.Say(1234);
        Hello<string> hs = new Hello<string>(); hs.Say("안녕");
        Hello<string> say = new Hello<string>("반갑습니다.");
        say.Say(); say.SayType();
    }
}

// 제네릭 클래스 설계
public class Hello<T>
{
    private T msg;
    public Hello() { msg = default(T); } // 생성자
    public Hello(T msg) { this.msg = msg; }
   
    public void Say() { Console.WriteLine("{0}", this.msg); }
    public void Say(T msg) { Console.WriteLine("{0}", msg); }
    public void SayType()
    {
        T temp; temp = default(T); // int이면 0으로, string이면 null로, bool이면 false로 알아서 type에 맞게 초기화 해준다.
        Console.WriteLine("{0}", temp);
    }
    //public void SayInt(int msg) { Console.WriteLine("{0}", msg); }
    //public void SayStr(string msg) { Console.WriteLine("{0}", msg); }
    //public void SayObj(object msg) { Console.WriteLine("{0}", msg); }
}

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

78. 특성(Attribute)  (0) 2009.08.18
77. 형식매개변수에 대한 제약조건  (0) 2009.08.18
75. 리스트제네릭클래스  (0) 2009.08.17
74. 예외처리  (0) 2009.08.17
73 . 연산자오버로드  (0) 2009.08.17
Posted by holland14
:


==> 리스트제네릭클래스.cs



using System;
using System.Collections.Generic;

public class 리스트제네릭클래스
{
    public static void Main()
    {
        // 정수형
        List<int> su = new List<int>();
        su.Add(10); su.Add(20); su.Add(30);
        for (int i = 0; i < su.Count; i++)
        {
            Console.WriteLine("{0}", su[i]);
        }

        // 문자열
        List<string> str = new List<string>();
        str.Add("안녕"); str.Add("반가워"); str.Add("또봐");
        for (int i = 0; i < str.Count; i++)
        {
            Console.WriteLine("{0}", str[i]);
        }

        // 개체형(테이블형태) : 문자열, 정수
        List<ProductInfo> lstProduct = new List<ProductInfo>();

        ProductInfo pi1 = new ProductInfo(); //[1] 속성 사용
        pi1.ModelName = "TV"; pi1.Quantity = 10;
        lstProduct.Add(pi1);
       
        //ProductInfo pi2 = new ProductInfo();
        //pi2.ModelName = "RADIO"; pi2.Quantity = 5;
        lstProduct.Add(new ProductInfo("RADIO", 5)); //[2] 생성자 사용 ==> 가장 추천하는 방법이다.

       
        //ProductInfo pi3 = new ProductInfo();
        //pi3.ModelName = "DVD"; pi3.Quantity = 3;
        lstProduct.Add(new ProductInfo() { ModelName = "DVD", Quantity = 3 }); //[3] 컬렉션/개체 초기화자

        //lstProduct.Add(pi1);
        //lstProduct.Add(pi2);
        //lstProduct.Add(pi3);

        // 출력 : 윈폼/웹폼에서는 DataSource 개념 적용
        for (int i = 0; i < lstProduct.Count; i++)
        {
            Console.WriteLine("{0}, {1}", lstProduct[i].ModelName, lstProduct[i].Quantity);
        }
    }

}



==============================================================================================



==> Product.cs



using System;

public class ProductInfo
{
    // 상품명
    public string ModelName { get; set; }

    // 판매량
    public int Quantity { get; set; }

    // 생성자
    public ProductInfo()
    {
        // Empty    //  ==> "사용하지 않는다."
    }

    public ProductInfo(string modelName, int quantity)
    {
        this.ModelName = modelName;
        this.Quantity = quantity;
    }

}

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

77. 형식매개변수에 대한 제약조건  (0) 2009.08.18
76. 제네릭클래스  (0) 2009.08.18
74. 예외처리  (0) 2009.08.17
73 . 연산자오버로드  (0) 2009.08.17
72. 변환연산자  (0) 2009.08.17
Posted by holland14
:

// 예외(Exception) : 오류(Error)
// 컴파일(문법) 오류 : 잘못 타이핑, 잘못된 문법이면 Visual Studio가 바로 잡아준다.
//     - 많이 타이핑, 많은 학습을 해야 한다.
// 런타임(실행) 오류 : 실행시 발생,
//     - 많은 테스트를 해봐야 한다.
// 논리(잘못된분석?) 오류 : 잘못된 분석/설계/구현(오탈자) 등등
//     - 많은 프로그램 작성 경험이 필요하다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 예외처리
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 5;
            int b = 0;
            //int c = 5 / 0; // 컴파일에러
            //int c = a / b; // 런타임에러 발생한다.
            int c = a + b; // 논리상 나누기가 필요한데, 더하기(+)를 해버렸다?
            Console.WriteLine("{0}", c);

            ExceptionHandling();
        }

        private static void ExceptionHandling()
        {
            //int a = 5;
            //int b = 0;
            // try에서 예외발생 : [2] [3]번 코드 실행
            // try에서 예외발생하지 않으면 : [3]번만 실행
            try
            {
                //[1] 예외 발생할만한 구문 넣어놓는곳...
                //int c = a / b; // 예외가 발생할만한 구문은 try절에...
                //throw (new Exception("내가 만든 에러")); // 예외를 던지다(발생) ==> throw는 에러를 발생시키는 구문이다.
                DivideByZeroException dbze = new DivideByZeroException("듀글래?");
                throw dbze; 
                // 위의 2줄을 간단히 한줄로 throw new DivideByZeroException("듀글래?");   <== 이렇게 써도 된다.
            }
            catch (Exception ex)
            {
                //[2] 예외가 발생했을 때에만 실행됨
                Console.WriteLine("예외발생 : {0}", ex.Message); // 메시지 출력
            }
            finally
            {
                //[3] 예외가 발생하던 안하던 실행
                Console.WriteLine("프로그램을 정상 종료합니다.");
            }
        }
    }
}

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

76. 제네릭클래스  (0) 2009.08.18
75. 리스트제네릭클래스  (0) 2009.08.17
73 . 연산자오버로드  (0) 2009.08.17
72. 변환연산자  (0) 2009.08.17
71. 반복기(Iterator)  (0) 2009.08.17
Posted by holland14
:


==> 연산자오버로드.cs



using System;

public class 연산자오버로드
{
    public static void Main()
    {
        // int 키워드를 Integer로 모방
        //Integer i = new Integer(10);
        Integer i = 10; // 위 라인 대체
        //Integer j = new Integer(20);
        Integer j = 20;
        //Integer k = new Integer(0);
        Integer k = 0;
        //i.Value++;를 i++;로 줄여쓰고 싶으면 단한연산자 오버로드 코드블록이 있어야 한다.
        i++; // 단항 연산자 오버로드
        --j;

        //k.Value = i.Value + j.Value;
        k = i + j; // 이항 연산자 오버로드
        k = k - i;
        Console.WriteLine(Integer.MaxValue);
        Console.WriteLine(Integer.MinValue);
        //Console.WriteLine(k.Value);
        Console.WriteLine(k); // ToString() 메서드 오버라이드
    }

}

public partial class Integer
{
    // 상수형 필드 : 상수는 반드시 선언 동시 초기화
    public const int MaxValue = int.MaxValue;

    // 읽기전용 필드 :  선언동시초기화 또는 생성자초기화
    public static readonly int MinValue = int.MinValue;

    // 정적생성자를 통해서 읽기전용필드 초기화 가능
    static Integer()
    {
        MinValue = int.MinValue;
    }
}




==============================================================================================



==> Integer.cs



using System;

public partial class Integer
{
    private int value;
    public Integer(int value)
    {
        this.value = value;
    }
    public int Value
    {
        get { return value; }
        set { this.value = value; }
    }

    // 변환연산자
    public static implicit operator Integer(int value)
    {
        return new Integer(value);
    }

    // ToString() 메서드 오버라이드
    public override string ToString()
    {
        return value.ToString(); // 기본 값을 외부에 개체명으로 공개
    }

    // 단항 연산자 오버로드
    public static Integer operator ++(Integer data)
    {
        return ++data.value;
    }

    public static Integer operator --(Integer data)
    {
        return --data.value;
    }


    // 이항 연산자 오버로드
    public static Integer operator +(Integer a, Integer b)
    {
        return (a.value + b.value);
    }

    public static Integer operator -(Integer a, Integer b)
    {
        return (a.value - b.value);
    }
}

'.NET프로그래밍 > C# 3.5 SP1' 카테고리의 다른 글

75. 리스트제네릭클래스  (0) 2009.08.17
74. 예외처리  (0) 2009.08.17
72. 변환연산자  (0) 2009.08.17
71. 반복기(Iterator)  (0) 2009.08.17
70. 암시적으로 형식화된 로컬 변수  (0) 2009.08.17
Posted by holland14
: