Your last foreach
loop has nothing in the scope. Either get rid of it or
foreach (DictionaryEntry pc in PinCode) { }
Question
I want to return an OrderedDictionary in my method, but I have an error with my code...
I don't know why I can't do that:
public OrderedDictionary getAllPortsInformations()
{
OrderedDictionary SerialPort = filtreXml("/catalog/cd/SerialPort", "SerialPort");
OrderedDictionary BaudRate = filtreXml("/catalog/cd/BaudRate", "BaudRate");
OrderedDictionary DataBits = filtreXml("/catalog/cd/DataBits", "DataBits");
OrderedDictionary StopBits = filtreXml("/catalog/cd/StopBits", "StopBits");
OrderedDictionary ParityBits = filtreXml("/catalog/cd/ParityBits", "ParityBits");
OrderedDictionary ReadTimeout = filtreXml("/catalog/cd/ReadTimeout", "ReadTimeout");
OrderedDictionary WriteTimeout = filtreXml("/catalog/cd/WriteTimeout", "WriteTimeout");
OrderedDictionary PinCode = filtreXml("/catalog/cd/PinCode", "PinCode");
OrderedDictionary output = new OrderedDictionary();
foreach (DictionaryEntry sp in SerialPort)
output.Add(sp.Key, sp.Value);
foreach (DictionaryEntry br in BaudRate)
output.Add(br.Key, br.Value);
foreach (DictionaryEntry db in DataBits)
output.Add(db.Key, db.Value);
foreach (DictionaryEntry sb in StopBits)
output.Add(sb.Key, sb.Value);
foreach (DictionaryEntry pb in ParityBits)
output.Add(pb.Key, pb.Value);
foreach (DictionaryEntry rt in ReadTimeout)
output.Add(rt.Key, rt.Value);
foreach (DictionaryEntry wt in WriteTimeout)
output.Add(wt.Key, wt.Value);
foreach (DictionaryEntry pc in PinCode)
output.Add(pc.Key, pc.Value);
return output;
}
Error: Error 1 'application.Xml.getAllPortsInformations ()': all code paths do not necessarily return a value
Solution
Your last foreach
loop has nothing in the scope. Either get rid of it or
foreach (DictionaryEntry pc in PinCode) { }
OTHER TIPS
Your last foreach does not do anything? Or is that a typo.