What is the difference between method and function !!!
Difference between method and function !!!
Collapse
X
-
Originally posted by AtranWhat is the difference between method and function !!!
I believe the technical difference is that a function is not in a class, whereas a method is.
You'll see method and member function used interchangeably which is fine (a function that is a member of a class, get it? Correct term when discussing C++). Function and method shouldn't be used interchangeably , but often will be.
I'd suggest you don't sweat it, they both represent blocks of code that do something and might return a value.
-mwalts -
Originally posted by mwaltsNot a whole lot.
I believe the technical difference is that a function is not in a class, whereas a method is.
You'll see method and member function used interchangeably which is fine (a function that is a member of a class, get it? Correct term when discussing C++). Function and method shouldn't be used interchangeably , but often will be.
I'd suggest you don't sweat it, they both represent blocks of code that do something and might return a value.
-mwaltsComment
-
In VB .net, there are two types of methods: functions and subroutines.
Subroutine Declarations:
[CODE=vb]Sub method-name(parameter-list)
declarations and statements
End Sub[/CODE]
Function Declarations:
[CODE=vb]Function method-name(parameter-list) As return-type
declarations and statements
....
return expression
End Function[/CODE]
So again, function is a method type that you can use to return values, where sub routines does not return a value. In fact, as you can see, a function or subroutine in Vb.net are both methods.
Example of a shared function in the FCL framework:
[CODE=vb]dim quad as integer = math.pow(2,4)[/CODE]
That will make, of course, quad = 16.
Hope that helped!Comment
Comment