What must every method have in C#?
Experience Level: Junior
Tags: C#
Answer
Every method in C# must have two parts:
- Method signature
- Method body
Method signature must have four parts:
- Access modifier
- Return data type
- Name
- Parameters (parameters are wrapped in rounded brackets and are delimited by comma)
Method body is wrapped in curly brackets.
Related C# job interview questions
In C# how do you call one method from another method where both method are inside of the same class?
C# JuniorWhat is an attribute in C#?
C# JuniorWhat do you know about methods in C#?
C# JuniorWhat is execution context in C#?
C# JuniorWhat is a local variable and where can it be declared in C#?
C# Junior