.


:




:

































 

 

 

 


Public virtual void Clear ()




public virtual bool Contains (object obj)

Public virtual object Peek()

Public virtual object Pop()

public virtual void Push (object obj) public static Stack Synchronized(Stack stack)

public virtual object[] ToArray()

 

Count , , ,

true, obj , false , ,

, , obj

Stack, stack

,

 

, , .

// Stack.

Using System;

Using System.Collections;

class StackDemo {

static void ShowPush(Stack st, int a) { st.Push(a);

Console.WriteLine(" : Push(" + a + ")"); Console.Write(" : "); foreach(int i in st)

Console.Write(i + " ");

Console.WriteLine();

}

static void ShowPop(Stack st) {

Console.Write(" : Pop -> "); int a = (int) st.PopO;

Console.WriteLine();

Console.Write(" : "); foreach(int i in st)

Console.Write(i + " ");

Console.WriteLine();

}

static void Main() {

Stack st = new Stack ();

Foreach(int i in st)

Console.Write(i + " ");

Console.WriteLine();

ShowPush(st, 22);

ShowPush(st, 65);

ShowPush(st, 91);

ShowPop(st);

ShowPop(st);

ShowPop(st);

try {

ShowPop(st);

} catch (InvalidOperationException) { Console.WriteLine(" .");

}

}.

}

. , InvalidOperationException, .

: Push(22)

: 22 : Push(65)

: 65 22 : Push (91)

: 91 65 22 : Pop -> 91 : 65 22 : Pop -> 65 : 22 : Pop -> 22 :

: Pop -> .

Queue

, : . , , .

. , . , , , , . , .

, , Queue. ICollection, IEnumerable ICloneable. , , . , , , 2,0.

Queue .

Public Queue()

public Queue (int capacity)

public Queue (int capacity, float growFactor) public Queue (ICollection col)

2,0. , , capaci ty, 2,0. ( capaci ty), ( growFactor 1,0 10,0). , col. , 2,0.

Queue , , , . . 25.8. . , Enqueue (). ' , Dequeue (). , , (). DequeueO () , , InvalidOperationException.

25.8. , Queue

 

 

 





:


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


:

:

,
==> ...

1673 - | 1612 -


© 2015-2024 lektsii.org - -

: 0.012 .