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 - C# Tutorial
From the course: C# Best Practices for Developers
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Method overloading5m 16s
-
(Locked)
Unit testing without parameters4m 5s
-
(Locked)
Unit testing with parameters2m 54s
-
(Locked)
Method chaining4m 7s
-
(Locked)
Constants vs. read-only fields5m 28s
-
(Locked)
Using properties correctly2m 11s
-
(Locked)
Using properties demo4m 29s
-
(Locked)
Auto-implemented properties1m 33s
-
(Locked)
Auto-implemented properties demo5m 13s
-
(Locked)
-
-
-