70-536. Parameter T . what is that?
ijas1981
Member Posts: 19 ■□□□□□□□□□
I'm unable to understand parameter T.
70-536 self prep kit page 245 .
using System.Collections.Generic;
using System.Collections.Specialized;
using System;
using System.Collections;
public class MyList<T> : System.Collections.ICollection, System.Collections.IEnumerable
{
public static void main(string[] args)
{
Console.WriteLine("hi");
Console.Read();
}
//
private ArrayList _innerList = new ArrayList();
public void Add(T val)
{
_innerList.Add(val);
}
public T this[int index]
{
get
{
return (T)_innerList[index];
}
}
// ICollection Members
#region ICollection Members
void System.Collections.ICollection.CopyTo(System.Array array, int index)
{
throw new System.Exception("The method or operation is not implemented.");
}
int System.Collections.ICollection.Count
{
get { throw new System.Exception("The method or operation is not implemented."); }
}
bool System.Collections.ICollection.IsSynchronized
{
get { throw new System.Exception("The method or operation is not implemented."); }
}
object System.Collections.ICollection.SyncRoot
{
get { throw new System.Exception("The method or operation is not implemented."); }
}
#endregion
// //
// IEnumerable Members
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
throw new System.Exception("The method or operation is not implemented.");
}
#endregion
// //
}
70-536 self prep kit page 245 .
using System.Collections.Generic;
using System.Collections.Specialized;
using System;
using System.Collections;
public class MyList<T> : System.Collections.ICollection, System.Collections.IEnumerable
{
public static void main(string[] args)
{
Console.WriteLine("hi");
Console.Read();
}
//
private ArrayList _innerList = new ArrayList();
public void Add(T val)
{
_innerList.Add(val);
}
public T this[int index]
{
get
{
return (T)_innerList[index];
}
}
// ICollection Members
#region ICollection Members
void System.Collections.ICollection.CopyTo(System.Array array, int index)
{
throw new System.Exception("The method or operation is not implemented.");
}
int System.Collections.ICollection.Count
{
get { throw new System.Exception("The method or operation is not implemented."); }
}
bool System.Collections.ICollection.IsSynchronized
{
get { throw new System.Exception("The method or operation is not implemented."); }
}
object System.Collections.ICollection.SyncRoot
{
get { throw new System.Exception("The method or operation is not implemented."); }
}
#endregion
// //
// IEnumerable Members
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
throw new System.Exception("The method or operation is not implemented.");
}
#endregion
// //
}
Comments
-
JDMurray Admin Posts: 13,090 AdminT = data type. Insert the data type you need to use where the T is. Generics are all about the type-safe use of any data type (int, string, class, object, etc.) in a collection.
-
crap I forgot my old pwd Member Posts: 250A generic works like this...Lets say I have an array of integers Array1<int>. If I try to add a string object to Array1, it will not let me. T is the type that the data structure can store.