What's the difference between a method and a function?

前端 未结 30 3251
粉色の甜心
粉色の甜心 2020-11-21 05:08

Can someone provide a simple explanation of methods vs. functions in OOP context?

30条回答
  •  醉话见心
    2020-11-21 05:39

    Difference Between Methods and Functions

    From reading this doc on Microsoft

    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 finalizers.

    So methods are the subset of the functions. Every method is a function but not every function is a method, for example, a constructor can't be said as a method but it is a function.

提交回复
热议问题