Abstract
In this chapter, we have taken a detailed look at defining, implementing, and using methods. Methods are the muscles of a C# program. The code statements contained in a method are executed to perform actions and calculations, and the definitions and modifiers define how those methods can be connected together. Without methods, there is no C# program.
We looked at the different types of parameter that can be used in methods, and we learned that parameters are how we pass data around a program. We explored overloading and overriding methods, which are two of the key concepts in object-oriented programming. Finally, we looked at some special kinds of methods: the Main method, the constructor, and so on. These special methods shape the way that programs are executed and objects are differentiated. Along the way, we saw several convenience features, ranging from optional parameters to compiler-generated iterator blocks. There was a lot of information to learn in this chapter, but a good understanding of methods is an essential foundation for effective C# programming.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2010 Adam Freeman
About this chapter
Cite this chapter
Freeman, A. (2010). Methods. In: Introducing Visual C# 2010. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4302-3172-1_9
Download citation
DOI: https://doi.org/10.1007/978-1-4302-3172-1_9
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4302-3171-4
Online ISBN: 978-1-4302-3172-1
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)