Q:

What’s the difference between a method and a function in c#?

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Here,  I am giving a simplified explanation, ignoring issues of scope, etc.

A function is a piece of code that is called by name. It can be passed data to operate on (i.e. the parameters) and can optionally return data (the return value). All data that is passed to a function is explicitly passed.

A method is a piece of code that is called by a name that is associated with an object. In most respects it is identical to a function except for two key differences:

A method is implicitly passed the object on which it was called.
A method is able to operate on data that is contained within the class (remembering that an object is an instance of a class – the class is the definition, the object is an instance of that data).

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Interview Questions and Answers,You Need To Know

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What is the difference between an abstract functio... >>
<< What is the difference between SessionState and Vi...