Yes, that works.
Thanks
David.
On Fri, 7 Mar 2008 12:15:45 -0500, Peter Ritchie
<[EMAIL PROTECTED]> wrote:
>How about:
> private static Dictionary<int, string> m_codestrings =
> new Dictionary<int, string>()
> {
> {
> 1,
> "A"
> },
> };
>
>On Fri, 7 Mar 2008 12:01:17 -0500, David Nicholson <[EMAIL PROTECTED]>
>wrote:
>
>>Is there a way to use the C# 3.5 collection and object initializers to
set
>>up a Dictionary<>? Such as:
>>
>> private static Dictionary<int, string> m_codestrings =
>> new Dictionary<int, string>()
>> {
>> new KeyValuePair<int, string>()
>> {
>> Key = 1,
>> Value = "A",
>> },
>> };
>>
>>This fails because Add() needs two parameters. Which is very reasonable,
>>but I just wondered whether I'm missing something.
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com