using System;
class pArray
{
public static int Sum(params int[] paramList)
{
int t = 0;
foreach (int i in paramList)
{
t += i;
}
Console.WriteLine("Using Parameter Array");
return t;
}
}
|
Class pArray
Public Shared Function Sum(ParamArray paramList As Integer()) As Integer
Dim t As Integer = 0
For Each i As Integer In paramList
t += i
Next
Console.WriteLine("Using Parameter Array")
Return t
End Function
End Class
|
class Program
{
static void Main()
{
Console.WriteLine(pArray.Sum(1, 2, 3, 4, 5));
Console.ReadLine();
}
}
|
Class Program
Private Shared Sub Main()
Console.WriteLine(pArray.Sum(1, 2, 3, 4, 5))
Console.ReadLine()
End Sub
End Class
|