IT. Expert System.

C#

params


By using the params keyword, you can specify a method parameter that takes a variable number of arguments. You can send a comma-separated list of arguments of the type specified in the parameter declaration or an array of arguments of the specified type. You also can send no arguments. If you send no arguments, the length of the params list is zero. No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration.

Syntax:
static int functionName(params int[] values)


Example:

using System;

class Program
{
    static void Main()
    {
	//
	// Call params method with one to four integer constant parameters.
	//
	int sum1 = SumParameters(1);
	int sum2 = SumParameters(1, 2);
	int sum3 = SumParameters(3, 3, 3);
	int sum4 = SumParameters(2, 2, 2, 2);
	//
	// Write results of the method invocations.
	//
	Console.WriteLine(sum1);
	Console.WriteLine(sum2);
	Console.WriteLine(sum3);
	Console.WriteLine(sum4);
    }

    static int SumParameters(params int[] values)
    {
	//
	// Loop through and sum the integers in the array.
	//
	int total = 0;
	foreach (int value in values)
	{
	    total += value;
	}
	return total;
    }
}

/*Output

1
3
9
8*/


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 230 / 158766128. Delta: 0.00391 с