+ 3
Are METHODS and FUNCTIONS the same thing?
12 Réponses
+ 9
function inside a class is a method...people saying there are no functions in C#, well i say there are the same..since C# is OOP, people are just used to the name method...but if u have used both Procedural and OOP based languages, you know they are the same...
+ 3
@Amitrajit Bose
As agnkowal said, there are no functions in C#. So, your question is a few incorrect. I mean less objective or not objective languages (e.g. Pascal, C++), when I wrote my answer. In these such void functions are called procedures. Not C#. However, I think that such void functions formally return void type value. Thus, function and methods terms are just refered to different methodologies. Sorry for my sloppy English.
+ 3
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).
http://stackoverflow.com/questions/155609/difference-between-a-method-and-a-function
+ 2
Yes method and function are same but in oop concept we call it method but in other language like c we call it functions
+ 1
Traditionally, the function has to return some value.
0
there are no funtions in C#. Evry "funtion" is in class so it is called "method"
0
But what is the difference between them?
0
Some people say that functions which are inside of a class are called methods, others say they mean the same.
0
not for all programing languages
0
You cannot write functions outside of classes in C#, it makes no sense; practically, as regards C#, functions are methods, methods are functions. A method refers to a function that lives in a class.
In a functional language you might not have either objects or classes, so calling functions 'methods' would make no sense. There is also a formal definition of a function, which would apply. In a language like, say, JavaScript, where you can have both methods on objects/classes and standalone functions, it makes sense to differentiate.
That being said: lambdas _are_ anonymous functions, and they definitely _aren't_ methods. `Func`s also create functions, and those functions, again, are not (or do not need to be) methods.
- 1
a "function" can stand as it is but a "method" have a function within it
- 2
@Romanov
But there are also void functions which do not return any value. Right?!
So?