Marking method parameters optional by specifying parameter defaults in C sharp Arabic #68

 Marking method parameters optional by specifying parameter defaults in C sharp Arabic #68

Suggested Videos

❑ Marking method parameters optional by specifying parameter defaults .



Optional Parameters

here are 4 ways that can be used to make method parameters optional.

1- Use parameter arrays –part 66.

2- Method overloading –part 67.

3- Specify parameter defaults – in this video.

4-Use optionalAttribute that is present in System.Runtime.InteroServices namespace.



Named Parameters

4-Use optionalAttribute that is present in System.Runtime.InteroServices namespace.
4-When we invoke this method as shown below ,”1” is passed as the argument for parameter “a” and “2” is passed as the argument for parameter ”b” default.,

My intention is to pass”2 ” as the argument for parameter “c”. To achieve this we can make use of named parameters , as shown below. Notice that , I have specified the name of the parameter for which value “2” is being passed.

Next Video: Marking method parameters optional by using OptionalAttribute.


Follow Us

YouTube

 If you want to download pptx : click Telegram

Facebook

Twitter

Instagram

Tik Tok




إرسال تعليق

أحدث أقدم