//Test Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSharpTest
{
public abstract class BaseClass
{
public abstract String Attribute
{
get;
set;
}
public abstract void Function(String value);
public abstract event EventHandler Event;
public abstract Char this[int Index]
{
get;
}
}
public class DeriveClass : BaseClass
{
private String attribute;
public override String Attribute
{
get
{
return attribute;
}
set
{
attribute = value;
}
}
public override void Function(String value)
{
attribute = value;
if (Event != null)
{
Event(this, new EventArgs());
}
}
public override event EventHandler Event;
public override Char this[int Index]
{
get
{
return attribute[Index];
}
}
}
}
//Display Result
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using CSharpTest;
namespace CSharpExam
{
class Program
{
static void OnFunction(object sender, EventArgs e)
{
for (int i = 0; i < ((DeriveClass)sender).Attribute.Length; i++)
{
Console.WriteLine(((DeriveClass)sender)[i]);
}
}
static void Main(string[] args)
{
DeriveClass tmpObj = new DeriveClass();
tmpObj.Attribute = "1234567";
Console.WriteLine(tmpObj.Attribute);
tmpObj.Event += new EventHandler(OnFunction);
tmpObj.Function("7654321");
Console.ReadKey();
}
}
}