When you retrieve an element from a generic collection, you do not have to determine its data type or convert it.įor the examples in this topic, include Imports statements for the and System.Linq namespaces. A generic collection enforces type safety so that no other data type can be added to it. If your collection contains elements of only one data type, you can use one of the classes in the namespace. For some collections, you can assign a key to any object that you put into the collection so that you can quickly retrieve the object by using the key.Ī collection is a class, so you must declare an instance of the class before you can add elements to that collection. Unlike arrays, the group of objects you work with can grow and shrink dynamically as the needs of the application change. For information about arrays, see Arrays.Ĭollections provide a more flexible way to work with groups of objects. There are two ways to group objects: by creating arrays of objects, and by creating collections of objects.Īrrays are most useful for creating and working with a fixed number of strongly typed objects. For many applications, you want to create and manage groups of related objects.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |