1 / 12

Methods in Programming

Methods in Programming. Jonathan Heimdal November 8, 2012 2A Computer Technology. Main Method. User Method. Main bodies of code go here Starts with capital letters Main can access user methods easily. Can be referred to several times in main Usually starts with lower case letters

sachi
Télécharger la présentation

Methods in Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Methods in Programming Jonathan Heimdal November 8, 2012 2A Computer Technology

  2. Main Method User Method • Main bodies of code go here • Starts with capital letters • Main can access user methods easily • Can be referred to several times in main • Usually starts with lower case letters • Used to shorten and simplify programs Method Comparison

  3. Method name isMain Main method has parameters inside parenthesis Main code goes inside opening and closing curly braces {CODE HERE} Main Method

  4. Method name is OpenReadWriteFileAsync User method has parameters inside parenthesis User Method

  5. Purposes for User Methods • Used to shorten and simplify programs • Saves time when writing large programs • Makes programs easier to read “A purpose for a user built method, is if, for example, you must use the same block of code several times in a program, you don’t have to retype the same block of code over and over. All you have to do is type the name of the method and the parameters in place of the block of code.” (Heimdal, 2012)

  6. All methods are outside of main • Methods are sometimes in separate class • Class variables can indicate methods How to Identify

  7. Constructors • Getters • Setters • Methods Types of “Methods”

  8. Identified by having the same name as class name • Can do similar actions methods can Constructors

  9. “Getters are types of methods that are similar to a read only pdf text file. It only allows the user to read what is displayed, and does not allow user to edit.” (Heimdal, 2012) • Gives only get access to user Getters

  10. “Setters are similar to getters except for that you may read and edit. Setters allow user to access and edit or use the code in the setter method.” (Heimdal, 2012) • Gives only set access to user Setters

  11. “Methods cannot be inside of other methods. However, a method can also rely on other methods. For example, in a method, you could have a block of code that instigates another action. This action is done by another method. So, a method can rely on other methods inside its’ own code to achieve the overall program.” (Heimdal, 2012) Methods inside of Methods?

  12. Heimdal, J. (2012, November 18). Purposes for Methods. (M. Tamietti, Interviewer) • Navneeth. (2012, July 22). Compiling Multiple main() methods in C#. Retrieved November 18, 2012, from www.wordpress.com: http://crmerp4bus.wordpress.com/2012/07/22/compiling-multiple-main-methods-in-c/ • Sabnis, M. (2012, April 6). Asynchronous Programming using C# 4.5 and Visual Studio 2011. Retrieved November 18, 2012, from www.dotnetcurry.com: www.dotnetcurry.com/ShowArticle.aspx?ID=797 Bibliography

More Related