Serialize Dictionary Collection が必要ですが、コードにエラーがあります。どこが間違っていたのですか?これは私のコードです。
Dictionary<country,string> Countries=new Dictionary<country,string>();
Countries.Add(new country() { code = "AF", iso = 4 }, "Afghanistan");
Countries.Add(new country() { code = "AL", iso = 8 }, "Albania");
Countries.Add(new country() { code = "DZ", iso = 12 }, "Algeria");
Countries.Add(new country() { code = "AD", iso = 20 }, "Andorra");
FileStream fs = new FileStream("John1.xml", FileMode.Create);
XmlSerializer xs = new XmlSerializer(typeof(Dictionary<country, string>));
xs.Serialize(fs, Countries);
クラスの国
public class country
{
public string code { get; set; }
public int iso { get; set; }
}