SlideShare uma empresa Scribd logo
1 de 24
CIS-166 Final
 Open book, open notes, open computer
 100 points
 True/false, multiple choice, fill-in, short
  answer
 Emphasis on material since midterm
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
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
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
Dim Statement for Arrays
Default Values

string[] 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)
Dim Statement for Arrays
Assigned Values

string[] 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
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"
Working with Arrays
   Use Loops to reference each element in
    the array
    ◦ For / Next
    ◦ For Each / Next
For Next Loop
Assume strNames[10] already declared

integer intCounter, intEnd
intEnd = strNames.GetUpperBound(0)
For (intCounter = 0; intcounter<=intEnd;
  intCounter++)
   {Console.Writeline(strNames[intCounter])}
For Each Loop
Assume strNames[10] already declared

foreach (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 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
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
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 namespace

Using System.Windows.Forms.Form

              Namespace
                               Name of the Class
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
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
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)
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
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
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 form's class
Writing Data Files
 Declare a new StreamWriter object
 Use StreamWriter's WriteLine
  method
 Call StreamWriter's Close method
Write and WriteLine Methods
 Write Method: Places items consecutively
  in the file with no separator
 WriteLine Method: Places an Enter
  (carriage return) between records
Reading Files
   Declare a new StreamReader object
    ◦ File must exist!
   Use StreamReader's ReadLine method
    ◦ Loop to retrieve multiple records
   Call StreamReader's Close method
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
Checking for End of File
 Use StreamReader's Peek Method
 Peek looks at the next element without
  actually reading it
 If you Peek beyond the last element the
  value returned is -1

Mais conteúdo relacionado

Mais procurados

c++ lecture 1
c++ lecture 1c++ lecture 1
c++ lecture 1sai kumar
 
Collection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanCollection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanZeeshan Khan
 
Feeding automated test by Joe Beale
Feeding automated test by Joe BealeFeeding automated test by Joe Beale
Feeding automated test by Joe BealeQA or the Highway
 
An Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in PythonAn Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in Pythonyashar Aliabasi
 
Python Dictionary
Python DictionaryPython Dictionary
Python DictionarySoba Arjun
 
Learning Web Development with Django - Templates
Learning Web Development with Django - TemplatesLearning Web Development with Django - Templates
Learning Web Development with Django - TemplatesHsuan-Wen Liu
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsPawanMM
 
Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7DanWooster1
 

Mais procurados (15)

Unit 2
Unit 2 Unit 2
Unit 2
 
c++ lecture 1
c++ lecture 1c++ lecture 1
c++ lecture 1
 
Collection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanCollection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshan
 
Feeding automated test by Joe Beale
Feeding automated test by Joe BealeFeeding automated test by Joe Beale
Feeding automated test by Joe Beale
 
Advanced c#
Advanced c#Advanced c#
Advanced c#
 
Js objects
Js objectsJs objects
Js objects
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
An Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in PythonAn Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in Python
 
Python Dictionary
Python DictionaryPython Dictionary
Python Dictionary
 
Advanced R cheat sheet
Advanced R cheat sheetAdvanced R cheat sheet
Advanced R cheat sheet
 
10- java language basics part4
10- java language basics part410- java language basics part4
10- java language basics part4
 
Learning Web Development with Django - Templates
Learning Web Development with Django - TemplatesLearning Web Development with Django - Templates
Learning Web Development with Django - Templates
 
Session 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, SetsSession 17 - Collections - Lists, Sets
Session 17 - Collections - Lists, Sets
 
Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7Java Chapter 05 - Conditions & Loops: part 7
Java Chapter 05 - Conditions & Loops: part 7
 
Javasession7
Javasession7Javasession7
Javasession7
 

Destaque (7)

Schemas 2 - Restricting Values
Schemas 2 - Restricting ValuesSchemas 2 - Restricting Values
Schemas 2 - Restricting Values
 
CIS 245 Final Review
CIS 245 Final ReviewCIS 245 Final Review
CIS 245 Final Review
 
CIS160 final review
CIS160 final reviewCIS160 final review
CIS160 final review
 
Cis245 Midterm Review
Cis245 Midterm ReviewCis245 Midterm Review
Cis245 Midterm Review
 
Stored procedures
Stored proceduresStored procedures
Stored procedures
 
3 sql overview
3 sql overview3 sql overview
3 sql overview
 
Normalization
NormalizationNormalization
Normalization
 

Semelhante a Cis166 Final Review C# (20)

5. c sharp language overview part ii
5. c sharp language overview   part ii5. c sharp language overview   part ii
5. c sharp language overview part ii
 
C# overview part 2
C# overview part 2C# overview part 2
C# overview part 2
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
C# Language Overview Part II
C# Language Overview Part IIC# Language Overview Part II
C# Language Overview Part II
 
CIS-166 Midterm
CIS-166 MidtermCIS-166 Midterm
CIS-166 Midterm
 
Midterm Winter 10
Midterm  Winter 10Midterm  Winter 10
Midterm Winter 10
 
ASP.NET Session 7
ASP.NET Session 7ASP.NET Session 7
ASP.NET Session 7
 
VB.net&OOP.pptx
VB.net&OOP.pptxVB.net&OOP.pptx
VB.net&OOP.pptx
 
collections
 collections collections
collections
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
1_7a6f85d03f132dcd9d7592bc4643be1c_MIT6_0001F16_Lec8.pdf
1_7a6f85d03f132dcd9d7592bc4643be1c_MIT6_0001F16_Lec8.pdf1_7a6f85d03f132dcd9d7592bc4643be1c_MIT6_0001F16_Lec8.pdf
1_7a6f85d03f132dcd9d7592bc4643be1c_MIT6_0001F16_Lec8.pdf
 
Chap 3 Python Object Oriented Programming - Copy.ppt
Chap 3 Python Object Oriented Programming - Copy.pptChap 3 Python Object Oriented Programming - Copy.ppt
Chap 3 Python Object Oriented Programming - Copy.ppt
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
array Details
array Detailsarray Details
array Details
 
unit 2 java.pptx
unit 2 java.pptxunit 2 java.pptx
unit 2 java.pptx
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
 

Mais de Randy Riness @ South Puget Sound Community College

Mais de Randy Riness @ South Puget Sound Community College (20)

SQL Constraints
SQL ConstraintsSQL Constraints
SQL Constraints
 
CIS145 Final Review
CIS145 Final ReviewCIS145 Final Review
CIS145 Final Review
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
CIS245 sql
CIS245 sqlCIS245 sql
CIS245 sql
 
CSS
CSSCSS
CSS
 
XPath
XPathXPath
XPath
 
XSLT Overview
XSLT OverviewXSLT Overview
XSLT Overview
 
Views
ViewsViews
Views
 
CIS282 Midterm review
CIS282 Midterm reviewCIS282 Midterm review
CIS282 Midterm review
 
CIS 145 test 1 review
CIS 145 test 1 reviewCIS 145 test 1 review
CIS 145 test 1 review
 
XML schemas
XML schemasXML schemas
XML schemas
 
Document type definitions part 2
Document type definitions part 2Document type definitions part 2
Document type definitions part 2
 
Document type definitions part 1
Document type definitions part 1Document type definitions part 1
Document type definitions part 1
 
DOM specifics
DOM specificsDOM specifics
DOM specifics
 
SQL overview and software
SQL overview and softwareSQL overview and software
SQL overview and software
 
Triggers
TriggersTriggers
Triggers
 
CIS 282 Final Review
CIS 282 Final ReviewCIS 282 Final Review
CIS 282 Final Review
 
SQL Server Stored procedures
SQL Server Stored proceduresSQL Server Stored procedures
SQL Server Stored procedures
 
SQL Server Views
SQL Server ViewsSQL Server Views
SQL Server Views
 
Indexes
IndexesIndexes
Indexes
 

Último

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 

Último (20)

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 

Cis166 Final Review C#

  • 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 Arrays Default Values string[] 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 Arrays Assigned Values string[] 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 Loop Assume strNames[10] already declared integer intCounter, intEnd intEnd = strNames.GetUpperBound(0) For (intCounter = 0; intcounter<=intEnd; intCounter++) {Console.Writeline(strNames[intCounter])}
  • 10. For Each Loop Assume strNames[10] already declared foreach (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 namespace Using 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 form's class
  • 20. Writing Data Files  Declare a new StreamWriter object  Use StreamWriter's WriteLine method  Call StreamWriter's 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 StreamReader's ReadLine method ◦ Loop to retrieve multiple records  Call StreamReader's 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 StreamReader's Peek Method  Peek looks at the next element without actually reading it  If you Peek beyond the last element the value returned is -1