Chapter 06 - An Introduction To Object Oriented Programming...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
An Introduction To Object Oriented Programming Chapter 6 Using Methods
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Microsoft Visual C# 2008, Third Edition 2 Understanding Methods Method Encapsulated series of statements that perform a task Using a method is called invoking or calling
Background image of page 2
Microsoft Visual C# 2008, Third Edition 3 Understanding Methods (continued)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Microsoft Visual C# 2008, Third Edition 4 Writing Methods with No Parameters and No Return Value Major reasons to create a method Code will remain short and easy to follow A method is easily reusable Code bloat Unnecessarily long or repetitive statements A method must include: Method declaration Also called a method header or method definition Opening curly brace Method body Closing curly brace
Background image of page 4
Microsoft Visual C# 2008, Third Edition 5 Writing Methods with No Parameters and No Return Value (continued) Method declaration Defines the rules for using the method and contains: Optional declared accessibility Optional static modifier Return type for the method Method name, or identifier Opening parenthesis Optional list of method parameters Closing parenthesis
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Microsoft Visual C# 2008, Third Edition 6 Writing Methods with No Parameters and No Return Value (continued) Optional declared accessibility Limits how other methods can use your method Possible access values Public Protected internal Protected Internal Private You can declare a method to be static or nonstatic Methods are nonstatic by default
Background image of page 6
Writing Methods with No Parameters and No Return Value (continued) Microsoft Visual C# 2008, Third Edition 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Microsoft Visual C# 2008, Third Edition 8 Writing Methods with No Parameters and No Return Value (continued) Every method has a return type Indicates what kind of value the method will return to any other method that calls it If a method does not return a value, its return type is void Method name must be a legal C# identifier Scope Area in which a variable is known You can place a method in its own file Or within the file of a program that will use it
Background image of page 8
Writing Methods with No Parameters and No Return Value (continued) Microsoft Visual C# 2008, Third Edition 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Writing Methods with No Parameters and No Return Value (continued) Microsoft Visual C# 2008, Third Edition 10
Background image of page 10
Writing Methods with No Parameters and No Return Value (continued) Microsoft Visual C# 2008, Third Edition 11
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/29/2010 for the course BUSI 12345 taught by Professor Mm during the Spring '10 term at Prince Sultan University.

Page1 / 43

Chapter 06 - An Introduction To Object Oriented Programming...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online