字符串中的字典跳过新行字符

时间:2015-05-23 09:22:43

标签: c# string dictionary decode encode

修改

(C#)我有一个字典编码为字符串,我想要将其检索回来。 问题是,我使用正则表达式,我得到没有'\ n'键的字典。

以下是控制台应用程序的代码预览:new EF7

如果可以看到,第一个和第二个词典不匹配。对不起,问题格式不好。

1 个答案:

答案 0 :(得分:1)

因为你的问题不够清楚。我将不得不在这里做一些假设。尝试将RegexOptions.Singleline选项添加到正则表达式中。

var dictionary = Regex.Matches(frequencies, @".\d+.", RegexOptions.Singleline).Cast<Match>().ToDictionary(x => Convert.ToByte(x.Value[0]), x => int.Parse(x.Value.Substring(1, x.Value.Length - 2)));

Test Online

相关问题