把代码打一边,然后看注释会明白很多。(新手用)
namespace MyInface
{
//显示接口是只能用接口调用。
//隐式接口和类都能调用。
public interface IBookList
{
void Add(string BookName);
void Append(string BookName);
void Remove(int position);
int Count { get;}
string this[int index] { get;set;}
}
//隐式调用
public class BookList : IBookList
{
private List<string> booklist = new List<string>();
#region IBookList 成员
public void Add(string BookName)
{
booklist.Add(BookName);
}
public void Append(string BookName)
{
booklist.Insert(booklist.Count, BookName);
}
public void Remove(int position)
{
booklist.RemoveAt(position);
}
public int Count
{
get
{
return booklist.Count;
}
}
public string this[int index]
{
get
{
return booklist[index];
}
set
{
booklist[index] = value;
}
}
#endregion
}