using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;namespace MyConnection
{
class MySelfList : IList
{
#region 自定义集合类里面的字段
object[] mydata = new object[5];
int count = 0;
#endregion
public bool IsFixedSize
{
get { return true; }
}
public bool IsReadOnly
{
get { return false; }
}
public object this[int index]
{
get { return mydata[index]; }
set { mydata[index] = value; }
}
public int Add(object value)
{
if (count<mydata.Length) mydata[count] = value;
{
return count++;
}
}
public void Clear()
{
count = 0;
}
public bool Contains(object value)
{
for (int i = 0; i < count; i++)
if (mydata[i].Equals(value))
return true;
return false;
}
public int Select(object value)
{
for (int i = 0; i < count; i++)
if (mydata[i].Equals(value))
return i;
return -1;
}
public int Count
{
get { return count; }
}
public void CopyTo(Array array,int index)
{
Array.Copy(mydata,index,array,0,mydata.Length);
}
public bool IsSynchronized
{
get{ return false;} }
public object SyncRoot
{
get { return this; }
}
public IEnumerator GetEnumerator()
{
return mydata.GetEnumerator();
}
#region 未实现的方法
public void Insert(int index,object value) { }
public void Remove(object value) { }
public void RemoveAt(int index) { }
#endregion
}
class Progrom{
static void Main(string[] args)
{
MySelefList ls = new MySelefList();
ls.Add("红色");
ls.Add("蓝色");
Console.WriteLine(ls[1]);
foreach (string t in ls)
{
Console.WriteLine(t);
}
Console.ReadKey();
}
}
}
错误提示:错误1“MyConnection.MySelefList”不实现接口成员“System.Collections.IList.IndexOf(object)” 不知道哪里错了,摆脱各位大大帮助解答感激不尽啊
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;namespace MyConnection
{
class MySelfList : IList
{
#region 自定义集合类里面的字段
object[] mydata = new object[5];
int count = 0;
#endregion
public bool IsFixedSize
{
get { return true; }
}
public bool IsReadOnly
{
get { return false; }
}
public object this[int index]
{
get { return mydata[index]; }
set { mydata[index] = value; }
}
public int Add(object value)
{
if (count<mydata.Length) mydata[count] = value;
{
return count++;
}
}
public void Clear()
{
count = 0;
}
public bool Contains(object value)
{
for (int i = 0; i < count; i++)
if (mydata[i].Equals(value))
return true;
return false;
}
public int Select(object value)
{
for (int i = 0; i < count; i++)
if (mydata[i].Equals(value))
return i;
return -1;
}
public int Count
{
get { return count; }
}
public void CopyTo(Array array,int index)
{
Array.Copy(mydata,index,array,0,mydata.Length);
}
public bool IsSynchronized
{
get{ return false;} }
public object SyncRoot
{
get { return this; }
}
public IEnumerator GetEnumerator()
{
return mydata.GetEnumerator();
}
#region 未实现的方法
public void Insert(int index,object value) { }
public void Remove(object value) { }
public void RemoveAt(int index) { }
#endregion
}
class Progrom{
static void Main(string[] args)
{
MySelefList ls = new MySelefList();
ls.Add("红色");
ls.Add("蓝色");
Console.WriteLine(ls[1]);
foreach (string t in ls)
{
Console.WriteLine(t);
}
Console.ReadKey();
}
}
}
错误提示:错误1“MyConnection.MySelefList”不实现接口成员“System.Collections.IList.IndexOf(object)” 不知道哪里错了,摆脱各位大大帮助解答感激不尽啊
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货