Lec_7_A.ppt

This preview shows page 1 - 7 out of 21 pages.

1 VISUAL PROGRAMMING Faisal Fayyaz W - 7
Image of page 1

Subscribe to view the full document.

2 CONTENT Collections Dictionaries Hash Tables Event Handling Delegates
Image of page 2
3 Collections - Group of related object - We can group objects using arrays or by making collections - Collections can grow and shrink (we can add elements and remove them) - Collection is a class, so we must declare it before we can add elements in a collection - If our collection contains objects of only one data type; we can make use of System.Collections.Generic - Generic collections ensure type safety and does not imply type casting overhead - Sometimes is necessary to hold more than one object in your program as an object, a part, of a bigger collection. - The main purpose of a collection is to supply a way of iterating through objects in a larger structure and perform some actions with them.
Image of page 3

Subscribe to view the full document.

4 Collections - The .NET Framework provides specialized classes for data storage and retrieval. These classes provide support for stacks, queues, lists, and hash tables. Most collection classes implement the same interfaces, and these interfaces may be inherited to create new collection classes that fit more specialized data storage needs. - Collection classes are defined as part of the System.Collections or System.Collections.Generic namespace. - Collection classes are defined as part of the System Collections or System.Collections.Generic namespace. - Most collection classes derive from the interfaces ICollection, IComparer, IEnumerable, IList, IDictionary, and IDictionaryEnumerator . - Using generic collection classes; provides increased type-safety and in some cases can provide better performance, especially when storing value types
Image of page 4
5 Collections ArrayList myArray = new ArrayList (); myArray.Add(1); myArray.Add(2); myArray.Add(3); myArray.Add(4); myArray.Add(5); foreach (int i in myArray) { Console.WriteLine(i.ToString()); }
Image of page 5

Subscribe to view the full document.

6 Array List Since all objects derive from the object
Image of page 6
Image of page 7
You've reached the end of this preview.
  • Winter '18
  • Dr Sibt
  • Type system, Associative array

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern