Reputation: 251
I want to loop through a collection of string values and insert them as attributes. Something like this:
foreach (var result in results)
{
var one = result.GetStuff();
var two = result.Find(one);
foreach (var user in users)
{
one.Properties["something"].Value = two.something;
}
}
'users' is a collection of string values. Where you see "something" (two places), I want to be using a string value from 'users'. How can I do this?
Upvotes: 2
Views: 146
Reputation: 499022
Looks like you are looking for a Dictionary
.
If you set the key type to a string
type, this will allow you to do as your code example, though the value types need to belong to one type.
See this page for information on how to use dictionaries in .NET (thanks @Filip Ekberg).
Upvotes: 3