Is the term "function" valid in C #?

I just started three years with my computational degree and was looking through course material. My application development module is based on C #. Throughout the material, the lecturer refers to what, as I know, is called “methods” as “functions”. I know that the term “functions” is used (for example) by C ++ for code, but I thought OOP used a “method” to distinguish between two different types of programming.

So, are these two interchangeable or should the lecturer use the term “methods”?

+4
source share
2 answers

The C # 3.0 specification states

1.3

A class type defines a data structure that contains data elements (fields) and functions (methods, properties, etc.).

1.6.7

Members that contain executable code are collectively known as members of the class. The previous section describes the methods that are the main view of function members. This section describes the other types of function members supported by C # constructors: constructors, properties, indexes, events, operators, and destructors.

And, of course, "anonymous functions" are called by this term. The phrase "member of a function or anonymous function" is often found in the specification, it is obvious that there is no exact shorter way to say "a piece of executable code".

+8
source

Well, by definition, a function is something that returns a value and should not have any side effects. Functional programming takes this paradigm to the extreme.

Unlike an operation or subroutine, it may not have a return value and instead have some side effect. Imperative programming depends on such things. The only language I worked with was actively forcing you to declare this Visual Basic (sub and function). In C #, you simply declare void as a return type if you don't have a function in the classical sense.

The term method was invented by AFAIK to distinguish object-oriented programming from other styles. Then the function that is part (element) of the object will be a method.

I hope this helps.

+2
source

All Articles