c# – Differences between methods, procedure, function, what each one is for and how they are declared in C #


How are methods, classes, procedures, and functions different in C # and how are they declared?


  • Procedure : It is a set of instructions that fulfill a task
  • Function : Like a procedure but returns a value
  • Class : Object-oriented programming concept, it is a way of encapsulating functionality, it contains fields and methods.
  • Method : It can be a procedure or a function, the difference is that it belongs to a class.


public class ConsoleTest
    public void Saludo()

    public int Suma(int a, int b)
        return a + b;

In this example,

  • ConsoleTest is a class
  • Saludo is a method and a procedure. As it does not return a value it is type void
  • Suma is a method and a function
Scroll to Top