1
我收到以下错误:由于你的currentProfile单人LINQ的 - 无法隐式转换类型“System.Collections.Generic.IEnumerable
Profile currentProfile;
public Profile ActiveProfile()
{
currentProfile = new Profile();
return currentProfile =
(from profiles in xmlDoc.Element("PlayerPofiles").Element("Online").Elements("Player")
where (string)profiles.Element("Active") == "True"
select new Profile
{
Name = (string)profiles.Element("Name"),
Sex = (string)profiles.Element("Sex"),
Avatar = (string)profiles.Element("Avatar").Attribute("path") ?? "",
Created = (DateTime)profiles.Element("Created"),
Birthday = (string)profiles.Element("Birthday"),
Wins = (string)profiles.Element("Ratio").Element("Win"),
Losses = (string)profiles.Element("Ratio").Element("Loss"),
Abandoned = (string)profiles.Element("Ratio").Element("Abandoned")
});
}
感谢Dotnetstep ...修复它。 – Yecats 2011-12-25 03:36:48
你应该省略这一行'currentProfile = new Profile();',这是完全不必要的,该方法也应该返回'Profile' – 2011-12-25 04:15:02
谢谢@KrisIvanov - 我已经删除了第一行。我很困惑,但为什么它应该返回Profile而不是currentProfile? – Yecats 2011-12-26 00:24:37