42
1
using System;
2
using System.Collections.Generic;
3
namespace TulesDemo
4
{
5
public class DogInfo
6
{
7
public int dogCount = 0;
8
public string dogName = "";
9
10
public DogInfo(int count, string name)
11
{
12
this.dogCount = count;
13
this.dogName = name;
14
}
15
}
16
public class Program
17
{
18
public static void Main()
19
{
20
var values = new List<double>() { 1, 1, 1, 1, 1 };
21
DogInfo obj = Calulate(values);
22
Console.WriteLine("There are {0} dogs are in my {1}", obj.dogCount.ToString(), obj.dogName);
23
}
24
25
//The function return type as Tuple<int, string>
26
private static DogInfo Calulate(IEnumerable<double> values)
27
{
28
int dogCount = 0;
29
foreach (var value in values)
30
{
31
dogCount++;
32
33
}
34
35
//Create the DogInfo clase instance to assigne the value.
36
DogInfo obj = new DogInfo(dogCount, "Home");
37
38
//Returning the DogInfo instance
39
return obj;
40
}
41
}
42
}
Cached Result
包含本金的加總:32
不包含本金的加總:12
不包含本金的加總:12