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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Aug 20, 2025, 9:12 PM
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 BrooksPosted Aug 21, 2025, 5:34 AM
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:
In short:
In C#, the term function is more general, while a method is a function that belongs to a class, struct, or object.