CodeDom和集合初始化程序 [英] CodeDom and collection initializers

查看:113
本文介绍了CodeDom和集合初始化程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种使用C#CodeDom生成字典初始化程序的方法?那些都受支持了吗?

Is there a way to generate a dictionary initializer using the C# CodeDom? Are those supported at all?

我想要:

private IDictionary<string, string> map = new Dictionary<string, string>
{
    { "Name", "Value" },
    ...
};

推荐答案

使用CodeDom构造是不可能的.它们未针对集合初始化程序进行更新.

This is not possible using the CodeDom constructs. They were not updated for collection initializers.

LukeH在关于3.5功能和CodeDom的主题上有一篇很棒的博客文章

LukeH has an excellent blog post on the subject of 3.5 features and the CodeDom

这篇关于CodeDom和集合初始化程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆