CIS-166 Final Open book, open notes, open computer 100 points True/false, multiple choice, fill-in, short  answer Emph...
Arrays List or series of values all referenced by  the same name Use an array to keep a series of variables  for later p...
Array Terms   Element    ◦ Individual item in the array   Index (or subscript)    ◦ Zero based number used to reference ...
Simple Array Example      studentNames Array        (0)   Janet Baker        (1)   George Lee        (2)   Sue Li        (...
Dim Statement for ArraysDefault Valuesstring[] strName = string[4] Results in an array of 4 elements:     strName(0), strN...
Dim Statement for ArraysAssigned Valuesstring[] departments = {"ACT", "MKT", "HR"}  Results in an array with 3 elements, e...
Referencing Array Elements   Use the Index(es) of the Element       strName(row)    (0) Sam Smith     strName[0] : "Sam S...
Working with Arrays   Use Loops to reference each element in    the array    ◦ For / Next    ◦ For Each / Next
For Next LoopAssume strNames[10] already declaredinteger intCounter, intEndintEnd = strNames.GetUpperBound(0)For (intCount...
For Each LoopAssume strNames[10] already declaredforeach (string Item in strNames)  {Console.Writeline(Item)]
Object Terminology Review   Object - like a noun, a thing    ◦ An object is based on a class Properties - like an adject...
Polymorphism   Overloading: Argument type determines    which version of a method is used    ◦ Example: MessageBox.Show m...
Specifying a Namespace  Namespaces are used in .Net to organize   classes and source files  When referring to classes in...
Instance versus Static Variables Instance variables or properties use a  separate memory location for each  instance of t...
Constructors and Destructors   Constructor: Method that    automatically executes when an object    is instantiated    ◦ ...
Collections   Group of objects    ◦ Can be strongly typed: all objects based on      the same class   Similar to an arra...
Item Property   Typically default property for a collection    ◦ Refer to collection object, followed by      location (i...
Text Data Files Actual data stored in files on disk  device File: Entire collection of data Records: Rows or lines, one...
Text File Handling A Stream is designed to transfer a  series  of bytes from one location to another Streams are objects...
Writing Data Files Declare a new StreamWriter object Use StreamWriters WriteLine  method Call StreamWriters Close method
Write and WriteLine Methods Write Method: Places items consecutively  in the file with no separator WriteLine Method: Pl...
Reading Files   Declare a new StreamReader object    ◦ File must exist!   Use StreamReaders ReadLine method    ◦ Loop to...
ReadLine Method Use to read previously saved data Each time it executes, it reads the next  line of data Always assign ...
Checking for End of File Use StreamReaders Peek Method Peek looks at the next element without  actually reading it If y...
Upcoming SlideShare
Loading in...5
×

Cis166 Final Review C#

595

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
595
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "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
  22. 22. Reading Files Declare a new StreamReader object ◦ File must exist! Use StreamReaders ReadLine method ◦ Loop to retrieve multiple records Call StreamReaders Close method
  23. 23. ReadLine Method Use to read previously saved data Each time it executes, it reads the next line of data Always assign the value from the read to a location, such as a label, text box, or string variable
  24. 24. Checking for End of File Use StreamReaders Peek Method Peek looks at the next element without actually reading it If you Peek beyond the last element the value returned is -1
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×