How can I apply indexer to Dictionary.Values (C# 3.0)
Posted
by Newbie
on Stack Overflow
See other posts from Stack Overflow
or by Newbie
Published on 2010-06-01T07:50:52Z
Indexed on
2010/06/01
8:03 UTC
Read the original article
Hit count: 175
I have done a program
string[] arrExposureValues = stock.ExposureCollection[dt].Values.ToArray();
for(int i = 0; i < arrExposureValues.Length; i++)
Console.WriteLine(arrExposureValues[i]);
Nothing wrong and works fine.
But is it possible to do something like the below
for(int i = 0; i < stock.ExposureCollection[dt].Count; i++)
Console.WriteLine(stock.ExposureCollection[dt].Values[i]);
This is just for my sake of knowledge (Basically trying to accomplish the same in one line).
Note: ExposureCollection is Dictionary<DateTime, Dictionary<string, string>>
First of all I have the doubt if it is at all possible!
I am using C# 3.0.
Thanks.
© Stack Overflow or respective owner