Cis166 Final Review C#
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Cis166 Final Review C#

on

  • 726 views

 

Statistics

Views

Total Views
726
Views on SlideShare
677
Embed Views
49

Actions

Likes
0
Downloads
7
Comments
0

2 Embeds 49

http://rriness.spscc.edu 48
https://waol5.blackboard.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Cis166 Final Review C# Presentation Transcript

  • 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. 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. 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. 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. 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. 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. 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. Working with Arrays Use Loops to reference each element in the array ◦ For / Next ◦ For Each / Next
  • 9. For Next LoopAssume strNames[10] already declaredinteger intCounter, intEndintEnd = strNames.GetUpperBound(0)For (intCounter = 0; intcounter<=intEnd; intCounter++) {Console.Writeline(strNames[intCounter])}
  • 10. For Each LoopAssume strNames[10] already declaredforeach (string Item in strNames) {Console.Writeline(Item)]
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. Writing Data Files Declare a new StreamWriter object Use StreamWriters WriteLine method Call StreamWriters Close method
  • 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. Reading Files Declare a new StreamReader object ◦ File must exist! Use StreamReaders ReadLine method ◦ Loop to retrieve multiple records Call StreamReaders Close method
  • 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. 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