Upcoming SlideShare
×

# Cis166 Final Review C#

750 views
664 views

Published on

Published in: Education, Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
750
On SlideShare
0
From Embeds
0
Number of Embeds
56
Actions
Shares
0
8
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Cis166 Final Review C#

1. 1. CIS-166 Final Open book, open notes, open computer 100 points True/false, multiple choice, fill-in, short answer Emphasis on material since midterm
2. 2. Arrays List or series of values all referenced by the same name Use an array to keep a series of variables for later processing such as ◦ Reordering ◦ Calculating ◦ Printing
3. 3. Array Terms Element ◦ Individual item in the array Index (or subscript) ◦ Zero based number used to reference the specific elements in the array ◦ Must be an integer Boundaries ◦ Lower Subscript, 0 by default ◦ Upper Subscript
4. 4. Simple Array Example studentNames Array (0) Janet Baker (1) George Lee (2) Sue Li (3) Samuel Hoosier (4) Sandra Weeks (5) William Macy (6) Andy Harrison (7) Ken Ford (8) Denny Franks (9) Shawn James
5. 5. Dim Statement for ArraysDefault Valuesstring[] strName = string[4] Results in an array of 4 elements: strName(0), strName(1), strName(2), strName(3)decimal[] decBalance= new decimal[100] Results in an array of 100 elements: decBalance(0), . . . , decBalance(99)
6. 6. Dim Statement for ArraysAssigned Valuesstring[] departments = {"ACT", "MKT", "HR"} Results in an array with 3 elements, each with a value, departments[0] is “ACT”Integer[] intActCode = {10, 20, 30, 40} Results in an array with 4 elements, each with a number stored
7. 7. Referencing Array Elements Use the Index(es) of the Element strName(row) (0) Sam Smith strName[0] : "Sam Smith" (1) Jill Creech strName[1] : "Jill Creech" (2) Paul Fry strName[2] : "Paul Fry" (3) Rich Wells strName[3] : "Rich Wells"
8. 8. Working with Arrays Use Loops to reference each element in the array ◦ For / Next ◦ For Each / Next
9. 9. For Next LoopAssume strNames[10] already declaredinteger intCounter, intEndintEnd = strNames.GetUpperBound(0)For (intCounter = 0; intcounter<=intEnd; intCounter++) {Console.Writeline(strNames[intCounter])}
10. 10. For Each LoopAssume strNames[10] already declaredforeach (string Item in strNames) {Console.Writeline(Item)]
11. 11. Object Terminology Review Object - like a noun, a thing ◦ An object is based on a class Properties - like an adjective, characteristics of object Methods - like a verb, an action or behavior, something the object can do Events - object response to user action or other events
12. 12. Polymorphism Overloading: Argument type determines which version of a method is used ◦ Example: MessageBox.Show method Overriding: Refers to a class that has the same method name as its base class ◦ Method in subclass takes precedence
13. 13. Specifying a Namespace  Namespaces are used in .Net to organize classes and source files  When referring to classes in a different namespace ◦ Write out the entire namespace ◦ Add an Imports Statement to include the namespaceUsing System.Windows.Forms.Form Namespace Name of the Class
14. 14. Instance versus Static Variables Instance variables or properties use a separate memory location for each instance of the object Static variables or properties use a single memory location that is available for ALL objects of a class ◦ Can be accessed without instantiating an object of the class ◦ Use the Static keyword to create Static Methods can also be created
15. 15. Constructors and Destructors Constructor: Method that automatically executes when an object is instantiated ◦ Create by writing a procedure using the Class Name, followed by any arguments Destructor: Method that automatically executes when an object is destroyed ◦ Microsoft discourages use of in .Net
16. 16. Collections Group of objects ◦ Can be strongly typed: all objects based on the same class Similar to an array ◦ Collection expands and contracts automatically Have common properties and methods ◦ Add, Remove, Count, Item (Indexer)
17. 17. Item Property Typically default property for a collection ◦ Refer to collection object, followed by location (in []) Returns a member of the group ◦ Typically based on location, but can use other values ◦ Data type depends on the type of objects the collection manages
18. 18. Text Data Files Actual data stored in files on disk device File: Entire collection of data Records: Rows or lines, one per entity Fields: Data elements (values) within a row
19. 19. Text File Handling A Stream is designed to transfer a series of bytes from one location to another Streams are objects that have properties and methods Found in the System.IO namespace File handling projects usually contain an Imports statement before the statement declaring the forms class
20. 20. Writing Data Files Declare a new StreamWriter object Use StreamWriters WriteLine method Call StreamWriters Close method
21. 21. Write and WriteLine Methods Write Method: Places items consecutively in the file with no separator WriteLine Method: Places an Enter (carriage return) between records