locked
are methods the same as functions?

    Question

  •  

         I am hoping that someone can shed some light on this. Are methods the C# version of functions? In a book I am reading they say that methods use standard function format when defining them. If they are basically the same as functions, is this just a term used with C#?

     

       ...........................................................................thanks

    Saturday, December 01, 2007 3:33 PM

Answers

  • Yes, they're the same.  In object-oriented design you deal with objects and their attributes (properties) and behaviour (methods).  It's common to use "method" instead of "function" when dealing with an object's/class's behaviour.

     

    Saturday, December 01, 2007 3:57 PM
  • "function" as something that only returns a value is a VB thing.

    Sunday, December 02, 2007 3:37 PM

All replies

  • Yes, they're the same.  In object-oriented design you deal with objects and their attributes (properties) and behaviour (methods).  It's common to use "method" instead of "function" when dealing with an object's/class's behaviour.

     

    Saturday, December 01, 2007 3:57 PM
  • thanks for the clarification

     

    Saturday, December 01, 2007 4:54 PM
  • The terminology probably comes from basic.  In basic a function returns something and a subroutine doesn't.  To refer to both of them the word method is used.  In C a subroutine is a function is a method.
    Saturday, December 01, 2007 10:24 PM
  • Even in C# (and Java, etc.) many people still use the term 'function' to refer to a method which returns a value.

     

    Sunday, December 02, 2007 2:11 PM
  • How do they refer to a function that doesn't return a value?

    Sunday, December 02, 2007 2:59 PM
  • They wouldn't call a method that doesn't return a value a function - it would just be a method.

     

    i.e., when used this way, 'function' is a special type of 'method' - there is no need for a name for the general 'method' - it's just 'method'.

     

    But it's better to just call a method a method and avoid 'function' altogether.

     

    Sunday, December 02, 2007 3:11 PM
  • "function" as something that only returns a value is a VB thing.

    Sunday, December 02, 2007 3:37 PM
  • Thanks to everyone that replied. I appreciate the help.

     

     

     

    Sunday, December 02, 2007 7:01 PM