Difference
between Functions and Methods
-
S.No Functions Methods 1 Functions do not have any reference variablesMethods are called by reference variables2 All data that is passed to a function is explicitly passedIt is implicitly passed the object for which it was called3 It does not have access controlling i.e.,Function(other than static functions) declares and defines anywhere in the code It has access controlling i.e.,Method should declare and define in the class only
4 Function applies to both object oriented and non-object oriented language(procedural language.eg. C, Scripting language eg; JavaScript etc) Method is only applicable to object oriented programming language like C++, C#, Java etc
Summary:
A
function is just a part of code that executes code and can return
something.
A
method is, in OOP, a function that is bound to a class. As in C#
there are no stand-alone functions, every function in C# is a method
No comments:
Post a Comment