c# optional parameters code example

Example 1: optional arguments c#

public void ExampleMethod(int required,
                          string optionalstr = "default string",
    				      int optionalint = 10)

Example 2: C# optional arguments

public void SomeMethod(int a, int b = 0){/*some code*/}

Example 3: optional parameter get request c#

public string GetFindBooks(string author="", string title="", string isbn="", string  somethingelse="", DateTime? date= null) 
{
    // ...
}

Example 4: how to pass an optional parameter in c# mvc asp.net

public ActionResult Index(string Country, int Regions = 2)