Represent a 2-tuple, or pair in CSharp
Description
The following code shows how to represent a 2-tuple, or pair.
Example
//from w w w .ja va 2 s.c o m
using System;
public class Example
{
public static void Main()
{
Tuple<string, Nullable<int>>[] scores =
{ new Tuple<string, Nullable<int>>("A", 78),
new Tuple<string, Nullable<int>>("B", 84) };
output(scores);
}
private static void output(Tuple<string, Nullable<int>>[] scores)
{
foreach (var score in scores)
{
if (score.Item2.HasValue)
{
Console.WriteLine(score.Item2.Value);
}
}
}
}
The code above generates the following result.