Difference between method and function !!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Atran
    Contributor
    • May 2007
    • 319

    Difference between method and function !!!

    What is the difference between method and function !!!
  • mwalts
    New Member
    • May 2007
    • 38

    #2
    Originally posted by Atran
    What is the difference between method and function !!!
    Not 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.

    -mwalts

    Comment

    • Atran
      Contributor
      • May 2007
      • 319

      #3
      Originally posted by mwalts
      Not 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.

      -mwalts
      Thanks for your help, it help me to build my short tutorial project.

      Comment

      • thiago777
        New Member
        • May 2007
        • 89

        #4
        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

        Working...