What is the difference between a function and a method in C #?
Is it the same or different? confused?
Loading
What is the difference between a function and a method in C #?
Is it the same or different? confused?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sam HobbsRank #107 · 20.5K reputationPosted Aug 20, 2025, 5:12 PM EDT
As has been said, the term function is not used in the context of C#. When it is used, it is processing that returns a value. In the BASIC language the only difference between a function and a subroutine is that a function returns a value and a subroutine does not.
Amy Brooks157 reputationPosted Aug 21, 2025, 1:34 AM EDT
In C#, both functions and methods refer to blocks of reusable code, but there is a key difference:
Function
A function is a block of code that performs a specific task and can exist independently.
In C#, strictly speaking, functions don’t exist outside of classes (since everything resides within a class or struct). However, the term is often used to describe static methods or global-like behaviors.
Method
A method is a function that is associated with a class, object, or struct.
Methods define the behavior of an object and usually operate on its data (fields/properties).
They can be instance methods (called on an object) or static methods (called on the class itself).
Example:
class Calculator { // Method (belongs to the class) public int Add(int a, int b) { return a + b; } // Static method (often loosely called a function) public static int Multiply(int a, int b) { return a * b; } }In short:
In C#, the term function is more general, while a method is a function that belongs to a class, struct, or object.