比较两个字典c#,得到相同的键
我有两本字典。一个是实际的字典(单词代表键,定义代表值),另一个是单词文件中存储在第二个字典中的单词比较两个字典c#,得到相同的键,c#,dictionary,word,C#,Dictionary,Word,我有两本字典。一个是实际的字典(单词代表键,定义代表值),另一个是单词文件中存储在第二个字典中的单词 //first dictionary var xdoc = XDocument.Load("dicoFrancais.xml"); var dico = xdoc.Root.Elements() .ToDictionary(a => (string)a.Attribute("nom"),
//first dictionary
var xdoc = XDocument.Load("dicoFrancais.xml");
var dico = xdoc.Root.Elements()
.ToDictionary(a => (string)a.Attribute("nom"),
a => (string)a.Element("DEFINITION"));
//second dictionary
Dictionary<string, string> motRap = new Dictionary<string, string>();
Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
Document document = application.Documents.Open("monfichiertxt.docx");
int count = document.Words.Count;
for (int i = 1; i <= count; i++)
{
string text = document.Words[i].Text;
motRap.Add(text, "blabla");
}
// Close word.
application.Quit();
//第一本字典
var xdoc=XDocument.Load(“dicoFrancais.xml”);
var dico=xdoc.Root.Elements()
.ToDictionary(a=>(字符串)a.Attribute(“nom”),
a=>(字符串)a.Element(“定义”);
//第二本词典
Dictionary motRap=新字典();
Microsoft.Office.Interop.Word.Application Application=新的Microsoft.Office.Interop.Word.Application();
Document=application.Documents.Open(“monfichiertxt.docx”);
int count=document.Words.count;
对于(inti=1;it,t=>dico[t])代码>
但它不起作用。
谁能帮帮我吗,
非常感谢。(对不起,我的英语不是很好)
我想比较两个字典的键,得到与第一个字典值相同的键
//first dictionary
var xdoc = XDocument.Load("dicoFrancais.xml");
var dico = xdoc.Root.Elements()
.ToDictionary(a => (string)a.Attribute("nom"),
a => (string)a.Element("DEFINITION"));
//second dictionary
Dictionary<string, string> motRap = new Dictionary<string, string>();
Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
Document document = application.Documents.Open("monfichiertxt.docx");
int count = document.Words.Count;
for (int i = 1; i <= count; i++)
{
string text = document.Words[i].Text;
motRap.Add(text, "blabla");
}
// Close word.
application.Quit();
“但它不起作用”这是什么意思?你得到了什么结果?你期望什么?第三本字典没有显示