using System;
class MainApp
{
delegate void stuff();
static void Main()
{
stuff s = new stuff(sugar);
stuff c = new stuff(cream);
stuff m = new stuff(milk);
stuff cafe = new stuff(coffee);
Console.WriteLine("비엔나 커피 만들기");
stuff vienna = s + c + cafe;
vienna();
Console.WriteLine();
stuff cafeaulait = s + m + cafe;
cafeaulait();
Console.WriteLine();
stuff black = cafeaulait - m - s;
black();
Console.WriteLine();
}
static void sugar()
{
Console.Write("sugar ");
}
static void cream()
{
Console.Write("cream ");
}
static void milk()
{
Console.Write("milk ");
}
static void coffee()
{
Console.WriteLine("coffee ");
}
}
using System;
class varista
{
delegate void stuff();
static void Main()
{
stuff c = cream;
stuff m = milk;
stuff cafe = coffee;
stuff s = suger;
stuff type1 = c + m + cafe;
type1();
Console.WriteLine();
c();
m();
cafe();
Console.WriteLine();
stuff black = type1 - m - c;
black();
Console.WriteLine();
stuff cafeore = c + s + m;
cafeore();
}
static void cream()
{
Console.Write("cream1 ");
}
static void milk()
{
Console.Write("milk2 ");
}
static void coffee()
{
Console.Write("coffee3 ");
}
static void suger()
{
Console.Write("suger4 ");
}
}
using System;
class client
{
private int ID;
public delegate void clientService(object sender , EventArgs args);
public event clientService Service;
public client(int ID)//생성자 client의 ID를 설정합니다
{
this.ID = ID;
}
public int clientID // client ID 프로퍼티 ID 를 읽어옵니다
{
get { return this.ID; }
}
public void fireEvent()
{
if(Service!=null)
{
EventArgs args = new EventArgs();
Service(this , args);
}
}
}
class MainApp
{
public static void OnEvent(object sender, EventArgs args)
{
client c = (client)sender;
Console.WriteLine("{0}", c.clientID);
}
public static void Main()
{
client clientA = new client(1);
clientA.Service += new client.clientService(OnEvent);
}
}
'Writer > WarmingUp Code' 카테고리의 다른 글
C# Thread 스레드 (0) | 2008.10.29 |
---|---|
C# 객체생성과제 (0) | 2008.10.20 |
C# 과제 (0) | 2008.10.17 |
abstract interface (0) | 2008.10.15 |
델리게이트 이벤트 소스 노가다 (0) | 2008.10.13 |
눈물의 소스 박스형 for와 if 사용 첨부 상철 상봉 오윤 (0) | 2008.10.09 |
소스 복습 (0) | 2008.10.08 |
객체지향 소스 (0) | 2008.10.07 |