Functions or methods are written under the class, and we can call them through the function name. First, we need to figure out why there is a function or method of this kind of thing? Here, we use the same way of thinking as in the previous article, starting with its purpose or practical value. This is sometimes the case when we are writing programs. For example, to find the factorial of a number. We'll write a series of statements to get our results. However, if we ask for the factorial of another number later, we have to rewrite it again. Of course, if you say copy and paste, that's really good. But what if there are a lot of things to change? This is obviously not a simple way. Because of this, we have our functions or methods.
How do we define a method? First, we say that the method is written below the class. Second, just like declaring variable variables, first write the keyword or modifier. Then, is the name of this method, which is the way we pick it up. Finally add parentheses and braces inside the method body. The method body is the repeating series of statements, and the parentheses are a format. If you ask, what is written in parentheses, the official argument is "parameter". Why do you have this? For example, you wrote a method for averaging, and you wrote the method name and parentheses and found it wrong. Why? Because you didn't ask for the average number. So, you have to define the method by writing the number of data types in parentheses, separated by ",". Then, when you quote, write those numbers in parentheses. In this way, you can write different numbers and get different results, which is like a function in math.
In fact, the latter struct or enum type is also a meaning. They are all created for a certain need, and it is not an abrupt thing. I suggest finding the simplest example and trying to understand it, which is definitely much better than rote learning. To cope with the more abstract concepts, I recommend using hierarchies. There is always a logical association between concepts, and it is excellent to understand their dependencies. Can not understand, just find a few examples to see it, want to back the estimate is not feasible.
C # Learning Experience (function method Class)