Convert and Copy Elements in a Stack to an Array : Stack « Collections « VB.Net Tutorial

VB.Net Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statements
5. Date Time
6. Class Module
7. Development
8. Collections
9. Generics
10. Attributes
11. Event
12. Stream File
13. GUI
14. GUI Applications
15. 2D Graphics
16. I18N Internationlization
17. Reflection
18. Regular Expressions
19. Security
20. Socket Network
21. Thread
22. Windows
23. XML
24. Database ADO.net
25. Design Patterns
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial » Collections » Stack 
8. 27. 3. Convert and Copy Elements in a Stack to an Array
 
 

 Option Strict On
 Imports System
 Imports System.Collections
 Class Tester
     Public Shared Sub DisplayValues(ByVal myCollection As IEnumerable)
         Dim As Object
         For Each o In myCollection
             Console.WriteLine(o)
         Next o
     End Sub

     Shared Sub Main( )
         Dim intStack As New Stack( )

         Dim As Integer
         For i = To 4
             intStack.Push((i * 5))
         Next i

         Console.WriteLine("intStack values:")
         DisplayValues(intStack)

         Const arraySize As Integer = 10
         Dim testArray(arraySizeAs Integer

         For i = To arraySize - 1
             testArray(i= i * 100
         Next i
         Console.WriteLine("Contents of the test array")
         DisplayValues(testArray)

         intStack.CopyTo(testArray, 3)
         Console.WriteLine("TestArray after copy:  ")
         DisplayValues(testArray)

         Dim myArray As Object( ) = intStack.ToArray( )

         Console.WriteLine("The new array:")
         DisplayValues(myArray)
     End Sub
 End Class

        
  
  


intStack values:
20
15
10
5
Contents of the test array
0
100
200
300
400
500
600
700
800
900
0
TestArray after copy:
0
100
200
20
15
10
5
700
800
900
0
The new array:
20
15
10
5

 
8. 27. Stack
8. 27. 1. Stack
8. 27. 2. Stack: Push, Pop and Peek
8. 27. 3. Convert and Copy Elements in a Stack to an Array
8. 27. 4. IsSynchronized
ww_w._j_a___v___a_2s__._c__o__m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.