제목 : Car.cs
글번호:
|
|
340
|
작성자:
|
|
레드플러스
|
작성일:
|
|
2009/08/14 오전 9:46:00
|
조회수:
|
|
5039
|
using System;
// Namespace
namespace Hyundai
{
// Class
public class Car
{
// Field
private string name;
// Constructor
public Car()
{
// Empty
}
public Car(string name)
{
this.name = name;
}
// Property
private int _Length;
public int Length
{
get { return _Length; }
set
{
_Length = value;
names = new string[value];
}
}
// Indexer
private string[] names;
public string this[int index]
{
get { return names[index]; }
set { names[index] = value; }
}
// Method
public void Show()
{
Console.WriteLine("{0}", name);
foreach (string s in names)
{
Console.WriteLine("{0}", s);
}
}
// Destructor
~Car()
{
names = null;
}
// Event
public event CarHandler Go;
// Event Handler
public void OnGo()
{
if (Go != null)
{
Go();
}
}
}
// Delegate
public delegate void CarHandler();
}