Skip to content

Instantly share code, notes, and snippets.

@cburgdorf
Created March 30, 2011 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cburgdorf/895116 to your computer and use it in GitHub Desktop.
Save cburgdorf/895116 to your computer and use it in GitHub Desktop.
Extension Method to Create a New Tuple based on an existing one and copy over the first Item
//Extension Method to Create a New Tuple based on an existing one and copy over the first Item
// C#
public static Tuple<T1, T2> WithItem2<T1, T2>(this Tuple<T1, T2> tuple, T2 newItem2)
{
return Tuple.Create(tuple.Item1, newItem2);
}
//Same Method in F#
let withItem2 newItem2 (originalItem1, _) = (originalItem1, newItem2 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment