+ 3

Are METHODS and FUNCTIONS the same thing?

2nd Sep 2016, 10:16 AM
Amitrajit Bose
Amitrajit Bose - avatar
12 odpowiedzi
+ 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...
3rd Sep 2016, 9:29 PM
Hacker Hacker
Hacker Hacker - avatar
+ 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.
3rd Sep 2016, 10:30 AM
SergeiRom
+ 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
1st Nov 2016, 12:03 AM
Hasan Al-Yazidi
Hasan Al-Yazidi - avatar
+ 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
6th Sep 2016, 9:13 AM
Imran Bashir
Imran Bashir - avatar
+ 1
Traditionally, the function has to return some value.
2nd Sep 2016, 8:00 PM
SergeiRom
0
there are no funtions in C#. Evry "funtion" is in class so it is called "method"
2nd Sep 2016, 12:02 PM
agnkowal
0
But what is the difference between them?
2nd Sep 2016, 12:50 PM
Amitrajit Bose
Amitrajit Bose - avatar
0
Some people say that functions which are inside of a class are called methods, others say they mean the same.
2nd Sep 2016, 1:20 PM
LaserHydra
LaserHydra - avatar
0
not for all programing languages
1st Nov 2016, 2:42 AM
shaik rafee
shaik rafee - avatar
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.
2nd Nov 2016, 5:53 PM
Daniel Couper
Daniel Couper - avatar
- 1
a "function" can stand as it is but a "method" have a function within it
10th Sep 2016, 6:05 AM
Brian Amos
Brian Amos - avatar
- 2
@Romanov But there are also void functions which do not return any value. Right?! So?
3rd Sep 2016, 3:23 AM
Amitrajit Bose
Amitrajit Bose - avatar