Subscribe

RSS Feed (xml)

How to Declare Collections in ASP.NET

The .NET Framework includes a number of commonly used collections.They are found in the


System.Collections namespace, and can hold any object type, which means they


can hold any type, because in .NET, all types inherit from object.This example demonstrates


this using a simple array list.


Sub Page_Load (Sender As Object, E As EventArgs)


Dim al As New ArrayList(5)


al.Add("one")


al.Add(2)


al.Add(False)


al.Add(New System.Object())



Response.Write("Successfully added " & al.Count & _




" different types of objects to an ArrayList.")


End Sub



Declaring and using collections in .NET is very straightforward. Later in this chapter,


you'll learn how to use some of the different collections included in the framework, as


well as how to create your own strongly typed collections.

No comments:

Variety in the Web World