System.Collections.IEnumerable,
ICloneable
{
...
public virtual int Add(
object value);
public virtual void Insert(int index, object value);
public virtual void Remove(object obj);
public virtual object this[int index] {get; set; }
}
However, rather than forcing programmers to manually wrap the stack-based integer in a
related
object wrapper, the runtime will automatically do so via a boxing operation:
static void Main(string[] args)
{
// Value types are automatically boxed when
// passed to a member requesting an object.
ArrayList myInts = new ArrayList();
myInts.Add(10);
Console.ReadLine();
}
If you wish to retrieve this value from the ArrayList object using the type indexer, you must
unbox the heap-allocated object into a stack-allocated integer using a casting operation:
static void Main(string[] args)
{
...
Do'stlaringiz bilan baham: