Category: Functions in C Sharp

Functions in C Sharp

Delegates

Delegates

A delegate is a type that enables you to store references to functions. Although this sounds quite involved, the mechanism is surprisingly simple. The delegate declaration specifies a return type and parameter list. After...

Command – Line Arguments in C#

Command – Line Arguments in C#

Command line programs are the parameters that are passed at the beginning of program wihout asking for input from the program itself. Example Command Line arguments are specified in Visual Studio as : Step...

The Main() Function

The Main() Function

Earlier, you saw that Main() is the entry point for a C# application and that execution of this function encompasses the execution of the application. That is, when execution is initiated, the Main() function...

Out Parameters C#

Out Parameters C#

In addition to passing values by reference, you can also specify that a given parameter is an out parameter by using the out keyword, which is used in the same way as the ref...

Pass By Reference

Pass By Reference

You want to pass the parameter by reference to make changes. This means that the function will work with exactly the same variable as the one used in the function call, not just a...

Parameter Arrays

Parameter Arrays

C# enables you to specify one (and only one) special parameter for a function. This parameter, which must be the last parameter in the function definition, is known as a parameter array . Parameter...

Function Parameters

Function Parameters

When a function is to accept parameters, you must specify the following: A list of the parameters accepted by the function in its definition, along with the types of those parameters . A matching...

Returning Values from functions

Returning Values from functions

The simplest way to exchange data with a function is to use a return value. Functions that have return values evaluate to that value, in exactly the same way that variables evaluate to the...

Defining and Using Functions

Defining and Using Functions

Starting with the basics, you look at simple functions that don ’ t exchange any data with code that calls them, and then look at more advanced function usage. The following example demonstrate things...

What are functions ?

What are functions ?

Functions in C# are a means of providing blocks of code that can be executed at any point in an application.   For example, you could have a function that calculates the maximum value...