来自字符串的字典跳过换行符

Dictionary from a string skips new line character

编辑

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

这是控制台应用程序的代码预览:dictionaries example

如果你能看到,第一和第二字典不匹配。对不起,问题格式不好。

因为你的问题不够明确。我将不得不在这里做一些假设。尝试将 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