C# Optional Arguments
using System;
namespace ConsoleApplicationSample
{
class ArrayBCA
{
#region C# Optional Arguments
public static void Main(string[] args)
{
add(12, 12); // Passing both arguments
add(10); // Passing only
required argument
}
static void add(int a, int b = 10) // second parameter is optional
{
Console.WriteLine(a + b);
Console.ReadKey();
}
public static void Main(string[] args)
{
add(12, 12); // Passing both arguments
add(12); // Passing one
argument
add(); // Passing No
argument
}
static void add(int a = 12, int b) // Making
first parameter as optional
{
Console.WriteLine(a + b);
Console.ReadKey();
}
#endregion
}
}
https://www.youtube.com/channel/UCKLRUr6U5OFeu7FLOpQ-FSw/videos
0 comments
Post a Comment