Optional Parameters in C#
Автор: VCreations Tech
Загружено: 2018-01-11
Просмотров: 1198
Описание:
Hello Friends,
As the name Suggests, Optional Parameters means we can pass Optional Values to Parameters in Function or methods.
Let us take an example to explain Optional Parameters,
Example:-
private void Test(string Lname,string Fname="James")
{
//rest of code
}
When i call this method Test(), then at that time Lname we need to pass and for Fname either we can pass or we cann't pass the value in it.
So we can call Test() like this,
Test("Evans"); // Here by default James take as Fname
Test("Evans","Chris"); // Here "Chris" take as Fname
We need to Use Optional Parameters, when we need to pass some default values in it.
Even if We can use [Optional] Keyword in Function defination like this and Which works Same.
private void Test(string Lname, [Optional] string Fname = "James")
{
//rest of code
}
Note:- To Use [Optional] you need to include this namespace using System.Runtime.InteropServices;
For more information you can follow below given Links,
blog: https://dotnet2developer.blogspot.in/...
Facebook: / vcreations.tecnologies.9
twitter: / followers
subscribe: / @vcreationstech
Wish You Success,
v creation Techs
(Technologies-99)
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: