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
C# for beginners
C# for beginners

Are you learning C#? Try our test we designed to help you progress faster.

Test yourself