Method uses
Hi I am new and I recently learn how to make a method but I can't really see the use of them. They only serve to organize the code or there are certain actions that can only be achieved with the methods?
thanks
3 Replies
Code reuse
Code reuse and organization, that's about the long and short of it
Methods are how you do things. No methods, no program behavior.
That is what makes C# a procedural (method-based) programming language. It allows for other paradigms as well of course.
Read more on the procedural style here:
https://en.m.wikipedia.org/wiki/Procedural_programming
Procedural programming
Procedural programming is a programming paradigm, classified as imperative programming, that involves implementing the behavior of a computer program as procedures (a.k.a. functions, subroutines) that call each other. The resulting program is a series of steps that forms a hierarchy of calls to its constituent procedures.
The first major procedu...
in addition to reuse, they help you manage complexity
instead of having a bunch of code in a pile that does a bunch of different things, you can put them in little boxes where you put some stuff in (arguments), something happens inside, and you get outputs (return value)
then you don't need to know what happens inside the box, only what the box does
and the stuff inside the box doesn't leak out into the rest of your program
this gets extended when you start using classes and OOP