The C form displays the message time method

  • 2021-01-06 00:42:54
  • OfStack

This article illustrates how the C# form displays message times. Share to everybody for everybody reference. The specific analysis is as follows:

Operating platform: Vs2012
The main implementation of such as space to publish the time display, such as: someone replied you 10 seconds ago this effect
Available in Web browsers, forms, etc...

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime now = DateTime.Now;
            DateTime time = Convert.ToDateTime( "2014-03-17 11:02:00");
            TimeSpan ts = now - time;
            if (time.Year == now.Year)
            {
                if (ts.Days < 1 && now.Day == time.Day)
                {
                    if (ts.Hours < 1)
                    {
                        if (ts.Minutes < 1)
                        {
                            string s=ts.Seconds.ToString() + " A second ago love me don't leave a message to you ";
                            Console.WriteLine(s);
                            Console.ReadLine();
                            return;
                        }
                        string a = ts.Minutes.ToString() + " A minute ago I love you don't leave a message ";
                         Console.WriteLine(a);
                         Console.ReadLine();
                         return;
                    }
                    string b = " today " + time.ToString("HH:mm") + " Love I don't leave a message to you ";
                    Console.WriteLine(b);
                    Console.ReadLine();
                    return;
                }
                Console.WriteLine(time.Month.ToString()+" month " + time.Day.ToString() +" day "+ time.Hour.ToString("#00")+" hours " + time.Minute.ToString("#00")+" Minutes ago "+" He left a message for you who loves you ");
            }
            Console.ReadLine();
        }
    }
}

I hope this article will be helpful to your C# program design.


Related articles: