0-23 hours from DateTime - CSharp System

CSharp examples for System:DateTime Hour

Description

0-23 hours from DateTime

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w  w  w .j  ava  2  s  .c  o m*/
using HandyWork.Common.Time;

public class Main{
        /// <summary>
        /// 0-23
        /// </summary>
        public static int Hour(this DateTime? dt)
        {
            if (dt == null)
            {
                return 0;
            }
            return dt.Value.Hour;
        }
}

Related Tutorials