The mutable tuple is similar to the .Net Framework Tuple but, would allow you to change each tuple element value.
Excerpt from (msdn article)
Tuples are commonly used in four ways:
- To represent a single set of data. For example, a tuple can represent a database record, and its components can represent individual fields of the record.
- To provide easy access to, and manipulation of, a data set.
- To return multiple values from a method without using out parameters (in C#) or ByRef parameters (in Visual Basic).
- To pass multiple values to a method through a single parameter. For example, the Thread.Start(Object) method has a single parameter that lets you supply one value to the method that the thread executes at startup time. If you supply a Tuple<T1, T2, T3> object as the method argument, you can supply the thread’s startup routine with three items of data.
The souce code is written in C# and targeted for the .Net Framework 2.0 and later. Download the entire project and compile.
Once you have compiled the project reference the dll in your Visual Studio project. Then in your code file add the following to the collection of using statement.
using Ekstrand;
When you want to use the mutable tuple in your code just type MTuple and follow the intellisense.
Example below use of MTuple<T> for string.
[inside some method]
MTuple<string> name = new MTuple<string>();
name.Item1 = tbxName.Text.Trim();
{ additional code examples please }
Class documentation on mutable tuple can be found here.
1.0.0 Initial release into the wild.
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are always welcome.
Fred Ekstrand email: fredekstrandgithub@gmail.com
This project is licensed under the MIT License - see the LICENSE.md file for details.
Mutable Tuple code is based on the .NET Framework reference source code for Tuple. ( Why reinvent the wheel? )
Starting with .Net 4.7 Microsoft has included ValueTuple which is the same ability as this code base.