Generics
ijas1981
Member Posts: 19 ■□□□□□□□□□
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
}
}
// C#
public class MyList<T> : ICollection, IEnumerable
{
private ArrayList _innerList = new ArrayList();
public void Add(T val)
{
_innerList.Add(val);
}
public T this[int index]
{
get
{
return (T)_innerList[index];
}
}
#region ICollection Members
void ICollection.CopyTo(Array array, int index)
{
throw new Exception("The method or operation is not implemented.");
}
int ICollection.Count
{
get { throw new Exception("The method or operation is not implemented."); }
}
bool ICollection.IsSynchronized
{
get { throw new Exception("The method or operation is not implemented."); }
}
object ICollection.SyncRoot
{
get { throw new Exception("The method or operation is not implemented."); }
}
#endregion
#region IEnumerable Members
IEnumerator IEnumerable.GetEnumerator()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
}
//can somebody explain me MyList<T>
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
}
}
// C#
public class MyList<T> : ICollection, IEnumerable
{
private ArrayList _innerList = new ArrayList();
public void Add(T val)
{
_innerList.Add(val);
}
public T this[int index]
{
get
{
return (T)_innerList[index];
}
}
#region ICollection Members
void ICollection.CopyTo(Array array, int index)
{
throw new Exception("The method or operation is not implemented.");
}
int ICollection.Count
{
get { throw new Exception("The method or operation is not implemented."); }
}
bool ICollection.IsSynchronized
{
get { throw new Exception("The method or operation is not implemented."); }
}
object ICollection.SyncRoot
{
get { throw new Exception("The method or operation is not implemented."); }
}
#endregion
#region IEnumerable Members
IEnumerator IEnumerable.GetEnumerator()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
}
//can somebody explain me MyList<T>
Comments
-
DeepCode Member Posts: 29 ■□□□□□□□□□http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx
gets no better than that!