| method-parameters/by-out-and-params/ex.cs - The class A with a DoAdd method - both out and params. | Lecture 5 - slide 27 : 29 Program 1 |
using System;
public class A{
private int a, b, c;
private int r;
public A(){
a = 1; b = 2; c = 3;
}
public void DoAdd(out int v, params int[] iv){
v = 0;
foreach(int i in iv)
v += i;
}
public override string ToString(){
return String.Format("{0} {1} {2}. {3}", a, b, c, r);
}
public void Go(){
Console.WriteLine("{0}", this);
DoAdd(out r, a, b, c);
Console.WriteLine("{0}", this);
DoAdd(out r, a, b, c, a, b, c);
Console.WriteLine("{0}", this);
DoAdd(out r);
Console.WriteLine("{0}", this);
}
public static void Main(){
new A().Go();
}
}