-1
我有一本字典:访问C#字典和返回值
Dictionary<ICD_Map2, string> maps = new Dictionary<ICD_Map2, string>();
我通过点击按钮添加到字典:
private void button2_Click(object sender, EventArgs e)
{
maps.Clear();
// Load mapping file.
var reader = new StreamReader(File.OpenRead(@"Call_Details_Map.csv"));
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(',');
maps.Add(new ICD_Map2(values[0].Replace("\"",""), values[1].Replace("\"","")), values[2].Replace("\"",""));
}
}
我想使用LINQ和我的钥匙映射到“字符串“在地图上。
我该怎么做?
var File001 = from line in File.ReadLines(ICD_process)
let l = line.Split(',')
where l[0] != "\"Statement Date\""
select new
{
CallType = maps.ToLookup(p => l[5], p => l[3]),
Calls = l[11] == "\"\"" ? "0" : (maps.ToLookup(p => l[5], p => l[3]) == "Mobile Data" || maps.ToLookup(p => l[5], p => l[3]) == "Mobile SMS") ? "0" : l[11].Replace("\"","").ToString())
};
我正在通话中的变量错误FILE001 LINQ的方法
什么是在字典中的价值?你能详细说明吗?示例键和您的地图中的值,输入和预期输出? –
@CuongLe我的词典看起来像: “Mobile SMS”| “澳大利亚”| “文本”; “手机短信”| “国际”| “海外文本”; “手机短信”| “其他”| “手机短信”; –
这是dic的价值吗? –