Hello friend,
My Codes:
public interface IEnumerable2{
void MethodOfIEnumerable2();
}
public interface ICollection2 : IEnumerable2{
void MethodOfICollection2();
}
public interface IList2 : ICollection2, IEnumerable2{
}
/// <summary>
/// Implement class.
/// </summary>
public class ArrayList2:IList2,ICollection2,IEnumerable2{
// Some members ...
public void MethodOfIEnumerable2(){
Console.WriteLine("IEnumerable2 In ArrayList2");
public void MethodOfICollection2(){
Console.WriteLine("ICollection2 In ArrayList2");
public void MethodOfIIList2() {
Console.WriteLine("IList2 In ArrayList2");
}
/// <summary>
/// Implement class.
/// </summary>
public class ArrayList3 : IList2{ // Also correct.
// Some members ...
public void MethodOfIEnumerable2(){
Console.WriteLine("IEnumerable2 In ArrayList3");
public void MethodOfICollection2() {
Console.WriteLine("ICollection2 In ArrayList3");
public void MethodOfIIList2(){
Console.WriteLine("IList2 In ArrayList3");
static void Main(string[] args) {
ArrayList2 al2 = new ArrayList2();
ArrayList3 al3 = new ArrayList3();
al2.MethodOfIEnumerable2();
al2.MethodOfICollection2();
al3.MethodOfIEnumerable2();
al3.MethodOfICollection2();
Now, My question is:
Because ICollection 2 inherited IEnumerable 2, so IList2 indirectly inherited IEnumerable 2, but in a statement IList2, we repeat inherited IEnumerable2. Seem to repeat inherited? The c# compiler team members do so for what purpose?
Thank in advance. :)