{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lec14 - Lecture 14 Generics PIC 10C Todd Wittman Exam 1...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Lecture 14: Generics PIC 10C Todd Wittman Exam 1 Monday square6 Meet in the PIC Lab Monday 11:00. (I will send you a reminder e-mail.) square6 Your exam will be 1/2 written, 1/2 programming. square6 The exam is open book, open notes. square6 The written part will focus on the C++ topics we covered in the first 2 weeks: STL containers & algorithms, Inheritance, Polymorphism. square6 The programming part will ask you to make a short program in C#. square6 Review questions are online.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Arrays square6 The built-in data container in C# is the Array. square6 It has more functionality than the C++ array, but it is still awkward for look-ups and making changes. square6 Ex Make a string array one bigger. string [] newArray = new string[array.Length+1]; for (int i=0; i<array.Length; i++) newArray[i] = array[i]; newArray[newArray.Length] = "Homer"; array = newArray; square6 This example is given on p. 295 of your book. Can you spot the error? Should be newArray.Length-1 Generics square6 C# is equipped with data structures similar to the STL containers. square6 C# calls them generics , because they can hold an abritrary data type. square6 The generics are defined in the library System.Collections.Generics , which is included for you automatically when you start a new project. square6 Their use is similar to C++, but the names are different so don't get them confused.
Image of page 2
3 Generics (p.297) C# Generic Data Structure C++ STL container List dynamic array vector SortedList binary tree set Dictionary hash table map LinkedList linked list list Queue queue queue Stack stack stack square6 There is also a C# generic called SortedDictionary,
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ 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