Question:what is optional parameters and named arguments?
Answer
Parameters are optional when a default value is specified as part of a declaration.
Example: public List<Product> GetProductByCategory(string category, int pageIndex=0){}
Here pageIndex is an optional parameter.
Named arguments allow us to explicitly name an argument we are passing to a method – instead of just identifying it by argument position.
Example: var products= GetProductByCategory(“beverages”, pageIndex=2){} here pageIndex is a named argument.