我正在尝试将此AddressParser(http://usaddress.codeplex.com/)从.Net 4.0转换为.Net 3.5,我遇到了一个小问题。
我在下面的注释行中收到cannot convert from 'System.Collections.Generic.Dictionary<string,string>.KeyCollection' to 'string[]'
错误。它特别强调rangelessSecondaryUnits.Keys
任何帮助转换它都会很精彩!
private static Dictionary<string, string> rangelessSecondaryUnits =
new Dictionary<string, string>()
{
{ "BA?SE?ME?N?T", "BSMT" },
{ "FRO?NT", "FRNT" },
{ "LO?BBY", "LBBY" },
{ "LOWE?R", "LOWR" },
{ "OFF?I?CE?", "OFC" },
{ "PE?N?T?HO?U?S?E?", "PH" },
{ "REAR", "REAR" },
{ "SIDE", "SIDE" },
{ "UPPE?R", "UPPR" }
};
var rangelessSecondaryUnitPattern =
@"(?<SECONDARYUNIT>" +
string.Join(
"|",
string.Join("|", rangelessSecondaryUnits.Keys)) + //ERROR ON THIS LINE
@")\b";
答案 0 :(得分:1)
删除您的string.Join
var rangelessSecondaryUnitPattern =
@"(?<SECONDARYUNIT>" +
string.Join("|", rangelessSecondaryUnits.Keys.ToArray()) +
@")\b";
除ToArray
之外,您的错误是在.NET3.5中没有超载需要params string[]
。但是,你的外部string.join
什么也没做,因为你的内部string.Join
正在返回一个字符串。