2

Beginner question: In a VB.net development environment, is it safe to assume the word "method" eventually refer us to the concept of functions or subroutines?

Eventually function is a block of instructions, created for modular programming purposes. It may have arguments that get passed into it and it certainly has to return something. Subs are likewise with no returns.

Excuse my ignorance but I'm just starting out to learn VB.net.

Amen Jlili
  • 1,884
  • 4
  • 28
  • 51

3 Answers3

5

In the OOP world, a "method" is technically a function or sub that is associated with a class.

For example:

Public Class [MyClass]
    Public Sub MyMethod()
    End Sub
End Class

MyMethod() is a method. If the sub was outside the class, it'd just be called a Sub or Function

You may hear other programmers refer to a method that is outside a class, but that is technically not correct.

Icemanind
  • 47,519
  • 50
  • 171
  • 296
2

Kind Of.

In Object Orientation, a method must belong to a class

However, VB.Net still allows Modules which are a hangover from procedural days, although these are implemented under the hood as static classes.

But the other way around, a method must be implemented as either a Sub (which has no return value and implies side-effects), or a Function (which has a return value, and in theory implies no side effects), if you follow CQS style convention.

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285
0

Assuming VB.net doesn't throw away general standards, a method is what you defined as a function or subroutine, but is attached to a particular object.

See this SO post for more information on the difference between methods and functions.

Community
  • 1
  • 1
Eric Palace
  • 322
  • 2
  • 14