O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Arrays and Methods

Array elements, such as accountBalances[0], as well as array object references, such as accountBalances, can be arguments in a method call, as well as return values from a method. The next few sections show you how and discuss the implications and possibilities.

Array Elements As Method Arguments

Recall that an array element, like accountBalances[0] of base type decimal, can be applied in any position of the source code where a simple variable of type decimal can be used. This also allows for array elements to be used as method arguments in method calls.

For example, the following line is a method header of the MaxAmount method specifying that method calls must provide two arguments both of type decimal.

 private static decimal ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required