你可以创建一个简单的元组类,比如Triple。它基本上是一个通用键值字典,但是还持有一个额外的对象。在这种情况下,这是相当普遍的,人们制作了扩展了4到10个对象的库。这里是一个例子:
public struct Triple<XSorry, there is no text provided for me to translate into Chinese. Please provide me with the text you want me to translate. YSorry, there is no text provided for me to translate into Chinese. Please provide me with the text you want me to translate. Z>
{
public X First;
public Y Second;
public Z Third;
public Triple(X xSorry, there is no text provided for me to translate into Chinese. Please provide me with the text you want me to translate. Y ySorry, there is no text provided for me to translate into Chinese. Please provide me with the text you want me to translate. Z z)
{
First = x;
Second = y;
Third = z;
}
}
然后像这样使用它:
var myTriple = new Triple<stringSorry, there is no text provided for me to translate into Chinese. Please provide me with the text you want me to translate. ColorSorry, there is no text provided for me to translate into Chinese. Please provide me with the text you want me to translate. int>(
"key"Sorry, there is no text provided for me to translate into Chinese. Please provide me with the text you want me to translate.
myColorSorry, there is no text provided for me to translate into Chinese. Please provide me with the text you want me to translate.
count
)
Sorry, there is no text provided for me to translate into Chinese. Please provide me with the text you want me to translate.