Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Named parameters in method signature

In C# - Optional parameters - creates a completion to the other un-supplied parameters.

so if I write:

void Go(int a, bool isFalse = true)

and call Go(a)

it actually emit il code for Go(a, true).

What about named parameters and how does switching the order thing works behind the scenes?

for example :

  Go(isFalse:true, a:1) //order has been switched.
like image 476
san.stifano Avatar asked Mar 28 '26 04:03

san.stifano


1 Answers

For example, if you have something like this

void Go ( int a , bool isFalse, bool isEmpty)

After your call Go(1,isEmpty : true, isFalse : false) it will generate function call like this

Go ( 1, false, true)
like image 92
Chuck Norris Avatar answered Mar 29 '26 19:03

Chuck Norris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!