From the course: C# Best Practices for Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Method overloading

Method overloading - C# Tutorial

From the course: C# Best Practices for Developers

Start my 1-month free trial

Method overloading

- [Instructor] In this chapter, I'd like to talk about naming and handling methods, fields, and properties. And we're going to start off with methods. Specifically, with the concept of overloading methods. Now, method overloading is used to create methods with the same name and purpose but different signatures. So there's a few things to point out. One is that the method names must be the same. Two, the number or type of parameters must be different. And that three, the return type isn't taken into account. So let's demonstrate an example. I'm going to navigate to our Actor class, and we're going to create two methods called BookActor that'll have different numbers of parameters. And the purpose of these methods is to indicate that the actor has been booked for some type of job. I'll scroll down to where we have our methods. And this is something that I definitely want to remind and point out, is that it's important to keep everything in order. It's common practice to have your…

Contents