IT254 Foundtations of Programming Using C# Unit 2 Seminar : (Chapter 1) Instructor : Vladimir...
-
Upload
cornelius-mathews -
Category
Documents
-
view
213 -
download
1
Transcript of IT254 Foundtations of Programming Using C# Unit 2 Seminar : (Chapter 1) Instructor : Vladimir...
IT254 Foundtations of Programming Using C#
Unit 2 Seminar :
(Chapter 1)
Instructor : Vladimir Gubanov, PhDEmail : [email protected]
A reminder:1. Our Seminars :
they will be each Wednesday , from 9 PM to 10 PM EST
2. My Office Hours :
Mondays, 7PM to 8PM
Saturdays, 9AM to 10 AM
3. My email :
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-3
Chapter Objectives - 1
• Describe the process of visual program design and development
• Explain the term object-oriented programming • Explain the concepts of classes, objects,
properties, methods, and events• List and describe the three steps for writing a
C# program• Describe the various files that make up a C#
project
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-4
Chapter Objectives - 2
• Identify the elements in the Visual Studio environment
• Define design time, run time, and debug time
• Write, run, save, print, and modify your first C# program
• Identify syntax errors, run-time errors, and logic errors
• Look up C# topics in Help
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-5
Writing Windows Applications
• Your C# programs will look and act like standard Windows programs
• Use tools to create:– Labels– Text boxes– Buttons– Radio buttons– Picture box– Check box– Menu Bar– Drop-down list– List box– Group box
What other applications different from Windows Applications can exist ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6
Windows Graphical User Interface (GUI)
• Windows GUI defines how elements look and function
• Windows are called forms
• Elements are called controls
• Add controls to your forms using the toolbox
• C# projects follow the object-oriented programming (OOP) technique
Name other types of User Interfaces different from GUI
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-7
Programming Languages—Procedural and Object Oriented
• Procedural — Basic, C, Cobol, Fortran, PL/1, Pascal– Program specifies exact sequence of
operations
• Object Oriented Programming (OOP) — C#, Java, Visual Basic– User controls the sequence– User actions cause events to occur which
trigger methods
When would you use Procedural laguages, when OOP ?Advantages of one against another?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-8
The Object Model
• A program is bulit as a collection of objects , each having well defined functionlaity
• Objects have properties, methods and events• An object is based on a class
– Objects (noun or thing)• Forms, Controls
– Properties (adjectives)• Name, Color, Size, Location
– Methods (verbs)• Close, Show, Clear
– Events (occurs when user takes action)• Click, KeyPress, Scroll, Close window
– Classes (template or blueprint)• Contain definition of all available properties, methods and events
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-9
OOP Terminology
• Object.Property– SalesForm.Text what does it mean ?
• Object.Method– BillingForm.Show what does it mean ?– exitButton.Show
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-10
Object Model Analogy
• Class = automobile type
• Object = one individual automobile– Object is an instance of the automobile class
• Properties = make, model, color, engine, number of doors
• Methods = start, speedup, slowdown, stop
• Events = arrive, crash
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-11
MS Visual Studio 2008 Features
.NET 3.5 Framework
– Environment that allows objects from different languages to operate together, standardizes references to data and objects
– .NET languages all compile (translate) to Microsoft Intermediate Language (MSIL)
– MSIL runs in the Common Language Runtime (CLR)• Programming Languages
– Visual C#, Visual C++, Visual Basic• C# Versions
– Express Edition, Standard Edition, Professional Edition, Team System
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-12
Writing C# Programs –The Three-Step Process (Planning)
• Planning– Design the user interface
• Sketch screens• Show forms and all controls
– Name forms and objects on form
• Consult with user
– Plan the properties– Plan the C# code
• Plan classes and methods• Write pseudocode
Who likes /does planning of future project ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-13
Writing C# Programs –The Three-Step Process (Programming)
• Define user interface– Create forms and controls
• Set the properties– Name each object and define its attributes
• Write the code– Define the actions of the program
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-14
C# Application Files
• Solution file– A C# application is called a solution and can consist
of one or more projects– .sln extension
• Project file– Describes project and lists files included– .csproj extension
• Form files– .cs, .Designer.cs, .resx extensions
• The Visual Studio environment creates several more files
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-15
The Visual Studio Environment
• Integrated development environment (IDE)– Includes various tools
• Form designer• Editor for entering and modifying C# code• Compiler• Debugger• Object Browser• Help
Which ones of those will you use most ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-16
The IDE Main Window
Each window can be moved, resized, closed, or customized
Solution Explorer
Properties window
Toolbox
Main Document window
Do not forget to name Project and Form properly at the benining – it will be harder to change the names later
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-17
The Form Designer
• Design forms for user interface• Change size of form using sizing handles or
selection border• A new default form is added when a new
C# application is started, again – do not leave a name as default Form1
• How to add a new form to the project , if needed ? How to delete the existing form ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-18
The Solution Explorer andProperties Windows
• Solution Explorer window– Holds filenames for project files– Lists classes referenced– Holds name of solution (.sln) file
• Properties Window– Used to set properties for objects in project
How to make a Solution Explorer window visible , if it is not shown ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-19
Toolbox
• Holds tools to place controls on form
• Tools vary depending on edition of C# and .NET version you work with
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-20
Design Time, Run Time, Debug Time
• Design Time– Design user interface (forms)– Write code
• Run Time– Testing project– Running project
• Debug Time– Run-time errors– Pause program execution
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-21
Writing Your First C# Project - 1
• Run Visual Studio
• Start a New Project– Select File/New/Project
• Visual C# and Windows must be selected for Project types
• Select Windows Forms Application for the template
– Enter Hello World as the project name– Click the OK button
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-22
Writing Your First C# Project - 3
• Set Up Your Environment– Click Window/Reset Window
Layout, Click Yes– Point to toolbox icon
• Pushpin icon toggles Auto Hide feature for toolbox
– Optional• Tools/Options• Options dialog box• Startup under Environment• At startup list
– Show empty environment
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-23
Writing Your First C# Project - 5
• Define the User Interface– Set Up the Form
• Drag handle to resize form
– Place Controls on the Form
Double-click the Label tool
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-24
Writing Your First C# Project - 9
• Lock the Controls– When controls are in desired location, lock them in
place– Unlock controls by clicking again on Lock Controls on
the context menu
Right-click on the form and select Lock Controls
A button that is selected and locked
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-25
Writing Your First C# Project - 11
• Change Properties of the Form– Text property appears in the form’s title bar– Set StartPosition property to CenterScreen
Icon indicates that the form’s controls are locked
Form’s Text property appears in the title bar
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-26
HelloForm.cs
Name of the form class
Name of the form’s file File name
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-27
Write Code
• C# Events– While a project is running the user can
perform actions, each of which causes an event to occur
– C# will execute a method when code has been written for an event
– C# ignores events for which no methods are written
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-28
C# Event Handlers
• Write C# code in methods– Each begins with the words private void– Code in method is enclosed in braces { }
• C# names the event-handling method as the object name, an underscore (_) and the name of the event– displayButton_Click
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-29
C# Code Statements
• Comment statements– Sometimes called remarks
• Ending a statement– Code statements are terminated by a semicolon (;)
• Assignment statements• Executing a Method
– Methods always have parentheses– Use this keyword to execute method of the current
form
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-30
The Comment Statement
• Comments or remarks are for project documentation• Explain purpose of the program• Provide identifying information• Non-executable statements within the code• Automatically colored green by the editor• Single-line comments begin with two slashes
// Display a message to the user.
• Multiline comments begin with /* and end with *//* First line
... Last line */
When would you use single line comments ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-31
Ending a Statement
• Most C# statements end with a semicolon (;)
• A statement can appear on multiple lines
• The semicolon determines the end of the statement
• Comments and a few other C# statements do not end with a semicolon
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-32
The Assignment Statement
• Assigns a value to a property or variable
• Operates from right to left– The value on the right side of the equal
sign is assigned to the property on the left side of the equal sign
• Enclose text (a literal) in quotation marks (" ")
messageLabel.Text = "Hello World";
What is the differentce bet ween “ = “ and “ == “ ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-33
Ending a Program by Executing a Method
• To execute a method of an object, write:Object.Method();
• Methods are always followed by parentheses– Can help distinguish methods from properties
• To execute a method of the current form use the this keyword
this.Close();
• this.Close() is used to end a program in the event-handling method for an Exit button or menu choice
What does “this” mean ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-34
Code Event-Handling Methods - 1
• Double-click the Display button• The Editor window opens• The header line for the method is in place• The insertion point appears inside the
opening and closing braces
private void displayButton_Click(object sender, EventArgs e){
|}
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-35
Code Event-Handling Methods - 2
Editor tab Form Designer tab
Comment statement
Assignment statement
Execute the Close method to end the program
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-36
Run the Project - 1
• Use one of three techniques to run– Open the Debug
menu / Start Debugging
– Press the Start Debugging toolbar button
– Press F5, the keyboard shortcut
IDE Title bar indicates program is in run time
Form for the running applicationEditor and Form Designer locked tabs
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-37
Save Your Work
• File menu/Save All– Saves the current form, project and solution
files
• Click Save All toolbar button to quickly save all files
• File menu/Close Solution– If file has not been saved since last change,
prompt to save appears
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-38
Automatically Generated Code
• Using Statements– Provide references to classes from the
language library• System.Windows.Forms
– Allows program to refer to all Windows controls
• Namespace Statement– .NET Framework requires every program
component to have a namespace
• Class Statement– A new class can inherit from another class
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-39
Finding and Fixing Errors
• Syntax errors– Breaking the rules of the language– Editor finds most, compiler reports remainder
• Editor identifies syntax errors with a red squiggly line
• Run-time errors or exceptions– Program halts due to statements that cannot execute
• For example, impossible arithmetic operations
• Logic errors– Program runs but produces incorrect results– Carefully proof output to make sure it is correct
• Computations, text and spacing
Which of those are harder to eliminate ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-40
Naming Rules and Conventions for Objects
• Follow C# rules for naming objects, methods and variables
• Good programmers follow naming rules and conventions
• Most programming shops have standards that must be followed
• When programmers consistently follow standards, programs are easier to read and to maintain, by both the original programmer and by others
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-41
The Naming Rules
• Name must begin with a letter or an underscore
• Name can contain letters, digits, and underscores
• Name cannot include a space, punctuation mark or be a reserved word
• Names in C# are case sensitive– exitbutton, ExitButton and exitButton refer
to three different objects
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-42
The Naming Conventions -1
• Follow standard naming conventions• Use camel casing
– Begin name with lowercase character– Capitalize each additional word in name
• Use meaningful names, indicate purpose of object
• Append full name of control’s class– Examples
• messageLabel, exitButton, discountRateLabel
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-43
The Naming Conventions - 2
• Do not keep C# default names– Exception is labels that never change during
execution
• Use pascal casing to name forms and classes– Capitalize first letter of name and first letter of
all other words in name– Examples
• HelloForm, MainForm, AboutForm
It is OK to use prefuxes as when coding VB
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-44
Visual Studio Help
• Installing and Running MSDN– Can be run from a hard drive or online
• Viewing Help Topics– Help window opens on top of IDE window– Filter by C# and either Express or Professional
Edition
• Context-Sensitive Help– Select a C# object (i.e. form or control)– Place insertion point in a word in the editor
• Press F1
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-45
Appendix C : Displaying Windows
• Windows can be opened quickly and easily when needed– Use the View menu– Buttons on the Standard Toolbar– Keyboard shortcuts
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-46
Display Windows UsingKeyboard Shortcuts
• Display keyboard shortcuts as part of popup tooltips– Select Tools/Customize/Toolbars tab/Show
shortcut keys in Screen Tips
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-47
Switch between Documents
• With several tabs open in the Document window, switch by clicking the document tabs or use the keyboard shortcuts
• Visual Studio displays only as many tabs as fit in the current size of the document window– If there are more documents than fit, use the drop-down list of
active files
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-48
Use the Full Screen
• Working in full-screen mode gives maximum screen space by getting rid of all extra windows– It also hides all toolbars
• Select View/Full Screen to display in full-screen mode
• Use the small Full Screen button to switch back to regular display – Or select View/Full Screen to toggle, or Shift+Alt+Enter
• To display the Text Editor toolbar while in full-screen mode, select View/Toolbars/Text Editor
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-49
Set Options for Your Work
• Choose Tools/Options to display the Options dialog box– Click each of the categories to see options that can
be selected• Projects and Solutions
– Set the default folder for projects• Text Editor
– Select C#• General: Select Auto list members and deselect Hide
advanced members– Word Wrap – Long lines wrap instead of extending beyond right
edge of screen• Tabs: Choose Smart indenting with a Tab size and Indent
size of 4
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-50
Comment and UncommentSelected Lines
• Comment Selected Lines– Remove lines from execution to test the effect
without actually removing them• Select lines of code and click the Comment
Selected Lines button
• Uncomment Selected Lines– Select commented lines and click the
Uncomment Selected Lines button
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-51
Use Keyboard ShortcutsWhen Editing Code
• Keyboard shortcuts save considerable time and are based on default keyboard mapping
• Most shortcuts from Microsoft Word work in the Editor Task Shortcut
Cut the current line to the clipboard (insertion point anywhere in the line).
Ctrl + L
Delete the current line without placing it in the clipboard (insertion point anywhere in the line).
Shift + Ctrl + L
Delete from the insertion point left to the beginning of the word.
Ctrl + Backspace
Delete from the insertion point right to the end of the word.
Ctrl + Delete
Complete the word. Ctrl + Spacebaror Alt + right arrow
Jump to a method (insertion point on method name). F12
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-52
Use Drag-and-Drop Editing
• To move code, select the text, point to the selection, and drag it to a new location
• Copy text (rather than moving it) by holding down the Ctrl key when dragging
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-53
Rename Variables and Objects
• Use Refactor/Rename to automatically rename all occurrences of a variable or object– Right-click on the name of the variable or object– In the context menu, select Refactor/Rename– In the Rename dialog box enter the new name– Changes the name in all occurrences in the current
form– Offers the option of changing in the entire project for
multiform projects
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-54
Use Context-Sensitive Help
• Quickest way to get Help is to use context-sensitive Help– Click a control or a line of code and press F1– Help displays the closest-matching item it can
locate
• Help for IDE elements is also available:– Click in any area of the IDE and press Shift +
F1• The Help explanation will be about using the current
window or IDE element
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-55
Use the Debugging Tools - 1
• Use the Debug Menu or toolbar for debugging
• Set breakpoints
• View the Contents of Expressions– Point to a variable or expression, the current
value pops up in a DataTip– Use the Locals window– Use the Autos window
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-56
Use the Debugging Tools - 2
• Single-step through Code– Stepping commands are Step Into, Step Over, and
Step Out– Continue rapid execution by choosing the Continue
command (F5)
• Write to the Output window– Place a Console.WriteLine method in code
• Specify a message to write or an object to track in the argument
• Output appears in the Output window• Do not have to break program execution to use
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-57
Copy and Move Projects
• Make sure that the project is not open• Copy the folder to a new location using Windows
Explorer• Rename the new folder, still using Windows Explorer• Open the new copy in the Visual Studio IDE• In the Solution Explorer, rename the solution and the
project• Rename the forms, if desired
– If you rename the startup form, open Program.cs and change the argument in the Application.Run method
• Open the Project Designer and change the assembly name and root namespace to the new project name
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-58
Deploy Applications
• Deployment—Distribution of an application to other computers
• Use either Windows Installer or click-once deployment– Windows Installer
• Open the Build menu, select Publish SolutionName• Launches Publish Wizard which gives options
• If you deploy to a folder on your system, you will find a Setup.exe application inside the folder– Copy the folder to another computer and install the
program there
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-5959
Types, Classes, and Objects
• Type
– C# has more than one type of number
– int type is a whole number
– floating-point types can have a fractional portion
• Types are actually implemented through classes – One-to-one correspondence between a class and a
type
– Simple data type such as int, implemented as a class
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6060
Type, Class, and Object Examples
Char : you know what an ASCII code is , right?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6161
Predefined Data Types
• Common Type System (CTS) • Divided into two major categories
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6262
Value Types
• Fundamental or primitive data types
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6363
Value Types (continued)
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6464
Integral Data Types
• Primary difference– how much storage is needed– whether a negative value can be stored
Why would you need so many types for numbers ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6565
Floating-point Types
• May be in scientific notation with an exponent• n.ne±P
– 3.2e+5 is equivalent to 320000
– 1.76e-3 is equivalent to .00176 • OR in standard decimal notation• Default type is double
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6666
Boolean variables
• Based on true/false, on/off logic
• Boolean type in C# → bool
• Does not accept integer values such as 0, 1, or -1
bool undergraduateStudent;
bool moreData = true;
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6767
Strings
• Reference type
• Represents a string of Unicode characters
string studentName;string courseName = “Programming I”;
string twoLines = “Line1\nLine2”;
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6868
Arithmetic Operations
• Simplest form of an assignment statementresultVariable = operand1 operator operand2;
• Readability– Space before and after every operator
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6969
Order of Operations
Can you use these operations with Strings ?
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-70
Quick Quiz
• Name two approaches used to design a solution.Answer: Procedural and object-oriented
• Give three examples of high level programming languages.
Answer: C#, Java, Visual Basic• True or False: .NET has been around since
the mid 1990s.
Answer: False
70
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-71
Quick Quiz
• True or False: All of the .NET Framework classes were written in C#.
Answer: False• Identify two reasons to use C# for developing
applications.• Answer: C# is a simple object-oriented language.
You can create graphical user interfaces with the same ease as was available only to Visual Basic programmers.
•
71
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-72
Quiz
• What are the type most common types of comments included in program? How are they distinguished? Answer: Block or multi-line and in-line or one line comments. Block comment use /* and */ to end the comment. In-line comments are added using two forward slashes.
• True or False: The Main ( ) method must be placed at the beginning of a program. Where to find the Main () method in the C# project ?
Answer: False• What is the relationship between the name of the file that contains
the program statement and the name of the class?Answer: They are named the same, except the file ends with a .cs file extension
72
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-73
Quiz (cont.)
• True or False: One valid identifier that follows the suggested rules for generating a name is StudentMajor. Answer: True
• What type of value can be stored in a double?Answer: A value, positive or negative, that may contain a fractional component.
• List two integral types available in the C# language?Answer: int and char
• Answer: float amount = 0.50f;
73
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-74
Quiz ( cont.)
• What is the purpose of these C# file types: .sln, .suo, and .cs?
• sln — The solution file. A text file that holds information about the solution and the projects it contains. This is the primary file for the solution—the one that you open to work on or run your project.
• .suo — Solution user options file. Stores information about the selected options, so that all customizations can be restored each time you open the solution.
• .cs — A .cs (C# ) file holds the definition of a form, its controls, and code methods. This is a text file that you can open in any editor. Warning: You should not modify this file unless you are using the editor in the Visual Studio environment.
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-75
• What is the purpose of the Name property of a control?• The Name property is used to refer to the control in the code.• What is a logic error, when does it occur, and what might cause
it?• A logic error produces incorrect output. The project may still run,
but the results are incorrect. Perhaps the results of a calculation are incorrect or the wrong text appears or the text is OK but appears in the wrong location.