serge
serge

Reputation: 15219

LINQ, convert Dictionary<int, bool> to Dictionary<string, string>

I have a

Dictionary<int, bool> articlesInfo = new Dictionary<int, bool>();

I need a the int and bool to be converted to string, into a

Dictionary<string, string>

How is it possible via something like

Dictionary<string, string> newDictionary = 
    articlesInfo.Select(x => x.ToString(), y => y.ToString());

Upvotes: 1

Views: 556

Answers (1)

canton7
canton7

Reputation: 42225

It's easiest to use Linq's ToDictionary:

var newDictionary = 
    articlesInfo.ToDictionary(x => x.Key.ToString(), x => x.Value.ToString());

Upvotes: 7

Related Questions