Download and view my resume (PDF)

Wednesday, June 16, 2010

Minimal C# Generic Pair Class

Here is an example of a Pair class for C#. This could be trivially modified or subclassed to provide a dictionary entry, other key/value pair, or larger number of values.

using System;

namespace WhateverNamespaceYouWant
{
///
/// This is a generic Pair class.
///

public class Pair
{
public Pair()
{
}

public Pair(T firstValue, U secondValue)
{
FirstValue = firstValue;
SecondValue = secondValue;
}

public T FirstValue { get; set; }
public U SecondValue { get; set; }
}
}

No comments:

Post a Comment