2

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?

2 Answers 2

3

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).

Sign up to request clarification or add additional context in comments.

Comments

0

one.Properties[user.SomeStringValue]

1 Comment

@spud, you can combind this with the answer from @Oded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.