In this video we're going to look at named parameters.
So named parameters are when you enter the name of the parameter when passing an argument okay.
What does that mean.
Well I have this program.cs here with a static int add num method.
And when I use this add num method, I can now enter the first number.
So let's say 15 and the second number let's say 25.
So I can do that.
And I can use a Console.WriteLine statement in order to print that out for example.
Right.
Whatever the result will be.
So this is one way of doing it.
Now let's take this and show you other ways where, for example, I could have said first num colon
is 23 comma and then whatever the second num is.
So by doing this this here is using the named parameter.
So the parameter is called first num.
So what I'm doing is I'm saying as the first num I want to use 23.
Now you can do the same thing for second num colon and that one will be 25.
So that is something you can do.
Then another way of doing it would be just one of them being available, and the other one would be
the second num or the second entry as second num.
And you can see in each case we do get the response, even though here it's 23 and other times it's
15.
So we do get the result here.
All of these variants work.
Now why would you do that?
Why would you use that?
Well, the thing is, in our case it's very simple because we only have two parameters.
But there are methods that have ten parameters.
And then it becomes a little complicated because you suddenly don't know what was the thing that you
entered the first number, is it the second number or whatever.
So doing it this way, you always know which parameter you're passing an argument to.
So this helps with readability, because this way you don't have to look up the method signature.
So the definition here this is the method signature where we see okay well the first one is an int first
num.
The second one is int second num.
So in this case we see it very well.
But it can be methods that have loads and loads of parameters 1015.
And then it's a combination of different types as well.
So one is an int, another one is a string.
The third one is maybe a of type of an object.
The fourth one is maybe a float or whatever.
So suddenly it becomes very complicated.
And then using the name of the parameter inside of the calling of the method.
So inside of, for example here will make it more readable for you after the fact.
Okay.
So that's pretty much what I wanted to show you.
So that's it for this video.
See you in the next one.