Task

Demonstrate the different syntax and semantics provided for calling a function.



This may include:

   Calling a function that requires no arguments
   Calling a function with a fixed number of arguments
   Calling a function with optional arguments
   Calling a function with a variable number of arguments
   Calling a function with named arguments
   Using a function in statement context
   Using a function in first-class context within an expression
   Obtaining the return value of a function
   Distinguishing built-in functions and user-defined functions
   Distinguishing subroutines and functions
   Stating whether arguments are passed by value or by reference
   Is partial application possible and how


This task is not about defining functions.




 
/* a function that has no argument */
	public int MyFunction();
 
	/* a function with a fixed number of arguments */
	FunctionWithArguments(4, 3, 2);
 
	/* a function with optional arguments */
	public void OptArg();
 
	public static void Main()
	{
		OptArg(1);
		OptArg(1, 2);
		OptArg(1, 2, 3);
	}
	public void ExampleMethod(int required, 
        string optionalstr = "default string",
		int optionalint = 10)
	/* If you know the first and the last parameter */
	ExampleMethod(3, optionalint: 4);
 
	/* If you know all the parameter */
	ExampleMethod(3, "Hello World", 4);
 
	/* Variable number of arguments use array */
	public static void UseVariableParameters(params int[] list) 
 
	/* Obtain return value from function */
	public internal MyFunction();
	int returnValue = MyFunction();
 