Posted by : Rhyf Ahmad Thursday, May 21, 2015

In the beginning there were variables, and they were good. The idea that you map a location in memory to a value was a key to tracking a value.However, most people want to work on data as a set. Taking the concept of a variable holding a value, you’ve moved to the concept of a variable that could reference an array of values.

Arrays improved what developers could build, but they weren’t the end of the line. Over time, certain patterns developed in how arrays were used. Instead of just collecting a set of values, many have looked to use arrays to temporarily store values that were awaiting processing, or to provide sorted collections. Each of these patterns started as a best practice for how to build and manipulate array data or to build custom structures that replicate arrays.
The computing world was very familiar with these concepts—for example, using a linked list to enable more flexibility regarding how data is sorted and retrieved. Patterns such as the stack (first in, last out) or queue (first in, first out) were in fact created as part of the original base Class Libraries. Referred to as collections, they provide a more robust and feature-rich way to manage sets of data than arrays can provide. These were common patterns prior to the introduction of .NET, and .NET provided an implementation for each of these collection types.
However, the common implementation of these collection classes relied on the Object base class. This caused two issues. The first, which is discussed in this chapter, is called boxing. Boxing wasn’t a big deal on any given item in a collection, but it caused a slight performance hit; and as your collection grew, it had the potential to impact your application’s performance. The second issue was that having collections based only on the type Object went against the best practice of having a strongly typed environment. As soon as you started loading items into a collection, you lost all type checking.
Solving the issues with collections based on the Object type is called generics. Originally introduced as part of .NET 2.0, generics provide a way to create collection classes that are type-safe. The type of value that will be stored in the collection is defined as part of the collection definition. Thus .NET has taken the type-safe but limited capabilities of arrays and combined them with the more powerful collection classes that were object-based to provide a set of collection classes which are type-safe.

Contents:

Arrays
  1. Multidimensional Arrays
  2. The UBound Function
  3. The ReDim Statement
  4. The Preserve Keyword

Collections
  1. Iterative Statements
  2. Boxing

Generics
  1. Using Generics
  2. Nullable Types
  3. Generic Types
  4. Generic Methods

Creating Generics
  1. Generic Types
  2. Generic Methods
  3. Constraints
  4. Generics and Late Binding
  5. Covariance and Contravariance





Ebook Preview
Get the ebook now (579 kB)

If the link above doesn't work, try the link below


Mirror: Get the ebook now (579 kB)

Leave a Reply

You can leave a comment to request any article(s), software(s), ebook(s) or report the dead link.
Then I will reply as soon as I can :)

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Recent Post

Recent Posts Widget
Instagram

- Copyright © Madriva -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -