.


:




:

































 

 

 

 


ArrayList . , , Synchronized().




ArrayList Capacity, , , .

public virtual int Capacity { get; set; }

Capacity ArrayList. , ArrayList . , ArrayList , . , . .

, ArrayList, Capacity. Count. , Count ICollection , . Capacity Count ArgumentOutOfRangeException. ArrayList, , Capacity Count. TrimToSize ().

ArrayList. ArrayList, , . , . , . , .

// ArrayList.

Using System;

Using System.Collections;

class ArrayListDemo { static void Main() {

// .

ArrayList al = new ArrayList ();

Console.WriteLine(" : " + al.Count);

Console.WriteLine();

Console.WriteLine(" 6 ");

// .

al.Add('');

al.Add(''); al.Add('E'); al.Add(11); al.Add('D'); al.Add(1F');

Console.WriteLine(" : " + al.Count);

// ,

// .

Console.Write(" : "); for(int i=0; i < al.Count; i++)

Console.Write (al[i] + " ");

Console.WriteLine("\n");

Console.WriteLine(" 2 ");

// , al.Remove('F'); al.Remove('A');

Console.WriteLine(" : " + al.Count);

// , foreach. Console.Write(": "); foreach(char in al)

Console.Write( + " ");

Console.WriteLine("\n");

Console.WriteLine(" 20 ");

// , // , for (int i=0; i < 20; i++) al.Add((char)('a' + i));

Console.WriteLine(" : " + al.Capacity);

Console.WriteLine(" 20 : " + al.Count);

Console.Write(": "); foreach(char in al)

Console.Write( + " ");

Console.WriteLine("\n");

// ,

// .

Console.WriteLine(" "); al [0] = 1X1; al[1] = 'Y'; al[2] = 'Z';

Console.Write(": "); foreach(char in al)

Console.Write (c + " ");

Console.WriteLine ();





:


: 2016-12-03; !; : 329 |


:

:

, .
==> ...

1395 - | 1199 -


© 2015-2024 lektsii.org - -

: 0.011 .