场景:。我在xml文件中有30个提示,现在我想按照天数在主页上显示它。在asp.net中按天数在主页上显示提示
例如,今天是12号,然后提示号码12将显示在主页上,之后13号等等。经过30个提示它将从尖1
我曾尝试下面的代码
public class TipReader
{
private const string TIP_XML_PATH = @"C:\temp\tips.xml";
public static int GetTipNumber()
{
int tipNo = 1;
if (DateTime.Now.Day >0)
{
if (DateTime.Now.Day == 31)
{
tipNo = 1;
}
else if (DateTime.Now.Day == 28)
{
tipNo = DateTime.Now.Day + 1;
}
else
{
tipNo = DateTime.Now.Day;
}
}
return tipNo;
}
public IEnumerable<Tip> GetTipByID(string ID)
{
var result = from tip in XDocument.Load(TIP_XML_PATH).Descendants("Tip")
where (string)tip.Element("ID")==ID
select new Tip
{
ImageUrl = (string)tip.Element("ImageUrl"),
Title = (string)tip.Element("Title").Value,
Desciption = (string)tip.Element("Description"),
};
return result;
}
}
现在,我就GetTipNumber面临的问题开始。如何处理日期大于30且小于30. 如果您有更好的解决方案,请给我建议。 在此先感谢
你有什么问题? – 2011-05-12 11:43:44
Abdul:没问题,有一些混淆:) – 2011-05-12 11:46:57