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
 
Midterm Winter 10
Midterm  Winter 10Midterm  Winter 10
Midterm Winter 10
 
CIS-166 Midterm
CIS-166 MidtermCIS-166 Midterm
CIS-166 Midterm
 
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

Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 

Último (20)

Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 

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