【发布时间】:2016-12-20 06:12:29
【问题描述】:
我在 .net 3.5 中运行了这段代码
public const string SvgNamespace = "http://www.w3.org/2000/svg";
public const string XLinkPrefix = "xlink";
public const string XLinkNamespace = "http://www.w3.org/1999/xlink";
public const string XmlNamespace = "http://www.w3.org/XML/1998/namespace";
public static readonly List<KeyValuePair<string, string>> Namespaces = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", SvgNamespace),
new KeyValuePair<string, string>(XLinkPrefix, XLinkNamespace),
new KeyValuePair<string, string>("xml", XmlNamespace)
};
private bool _inAttrDictionary;
private string _name;
private string _namespace;
public string NamespaceAndName
{
get
{
if (_namespace == SvgNamespace)
return _name;
return Namespaces.First(x => x.Value == _namespace).Key + ":" + _name;
}
}
我目前正在将其转换为 .net 2.0(删除 System.Linq)。如何维护在我的代码中找到 here 的 Enumerable.First Method (IEnumerable, Func) 的功能?
完整来源file
【问题讨论】:
-
什么是命名空间?这里没有同名的变量
-
@Steve,有一个
public static readonly List<KeyValuePair<string, string>> Namespaces -
@Rahul 我现在看到了,但我的借口是,如果您查看发布的链接中的源代码,事情会变得非常混乱。
-
@Steve,哈哈,你真的浏览过那个源代码链接吗:)