Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the term 'function' valid in c#?

Ive just started year three of my computing degree and have been looking through the course material. My application development module is based around c#. Throughout the material the lecturer refers to what I know to be called 'methods' as 'functions'. I am aware that the term 'functions' is used (for example) c++ for as code block but I thought that OOP used 'method' to distinguish between the two different types of programming.

So, are the two interchangeable or should the lecturer be using the term 'methods'?

like image 201
Dylan Jackson Avatar asked Dec 28 '22 13:12

Dylan Jackson


1 Answers

The C# 3.0 spec says

1.3

A class type defines a data structure that contains data members (fields) and function members (methods, properties, and others).

1.6.7

Members that contain executable code are collectively known as the function members of a class. The preceding section describes methods, which are the primary kind of function members. This section describes the other kinds of function members supported by C#: constructors, properties, indexers, events, operators, and destructors.

And of course "anonymous functions" are called by exacly that term. The phrase "function member or anonymous function" occurs a lot in the spec, there apparently being no accurate shorter way to say "lump of executable code".

like image 81
AakashM Avatar answered Dec 30 '22 09:12

AakashM