I want to create Key/Value Pair but with only one Set, not Dictionary with multiple pairs. (I don't want to use Array of size 2.)
What is the best way to do in C#?
I want to create Key/Value Pair but with only one Set, not Dictionary with multiple pairs. (I don't want to use Array of size 2.)
What is the best way to do in C#?
You're looking for a KeyValuePair<TKey, TValue>
:
var keyValuePair = new KeyValuePair<int, int>(1, 1);
For temporary/internal use you can do with anonymous object:
var item = new {
name = "myName",
value = 456
};