Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4609654
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:01:10+00:00 2026-05-22T01:01:10+00:00

Scenario: .I have 30 tips in xml file, now I want to display it

  • 0

Scenario:.I have 30 tips in xml file, now I want to display it on home page by day number.

For example, today is the 12th then tip number 12 will be displayed on the home page and after that 13 and so on. After 30 tips it will start from tip 1.

I have tried following code

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;
    }
}

Now, I am facing issue on GetTipNumber. How would I handle date greater than 30 and less than 30.
If you have better solution for this please suggest me.
Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:01:11+00:00Added an answer on May 22, 2026 at 1:01 am

    What is the harm in doing it in this fashion

    public static int GetTipNumber()
    {
         int tipNo = 1;
         if (DateTime.Now.Day > 0 && DateTime.Now.Day <= 30)
         {
             tipNo = DateTime.Now.Day;
         }
         else 
         {
             tipNo = 1; // 
         }                
    
         return tipNo;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I have several services that I want to be discovered by different clients.
Any examples, tips, guidance for the following scenario? I have retrieved updates from several
Any examples, tips, guidance for the following scenario? I have used Apache HttpClient to
Scenario: I have a ListBox and the ListBoxItems have a DataTemplate. What I want
Provide some tips to get rid of the following scenario. Description: I have two
Does anyone have any tips for this scenario. My app delegate's nib has a
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
SCENARIO I have to access a web service with a .NET client. The service
Scenario: I have a console application that needs to access a network share with
Scenario: I have an outline where I have links for my menu. Each link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.