C#里操作时间的例子!

众选

众选

2016-01-29 13:56

C#里操作时间的例子!,C#里操作时间的例子!
namespace Wrox.SampleCode.CSharpPreview.ChBaseClasses
{
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.WinForms;
using System.Data;
public class FormDisplayDateTimes : System.WinForms.Form
{
... as before

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com)

/// <summary
/// Summary description for FormDisplayDateTimes.
/// </summary public FormDisplayDateTimes()
{
//
// Required for Win Form Designer support
//


InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
// DateTime dtCurrTime = DateTime.Now;
AddItem("Current Time is " + dtCurrTime.ToString());
AddItem("Year is " + dtCurrTime.Year.ToString());
AddItem("Month is " + dtCurrTime.Month.ToString());
AddItem("Day of month is " + dtCurrTime.Day.ToString());
AddItem("Day of week is " + dtCurrTime.DayOfWeek.ToString());
AddItem("Hour is " + dtCurrTime.Hour.ToString());
AddItem("Minute is " + dtCurrTime.Minute.ToString());
AddItem("Second is " + dtCurrTime.Second.ToString());
AddItem("Millisecond is " + dtCurrTime.Millisecond.ToString());
AddItem("ShortDateString is " + dtCurrTime.ToShortDateString());
AddItem("LongDateString is " + dtCurrTime.ToLongDateString());
AddItem("ShortTimeString is " + dtCurrTime.ToShortTimeString());
AddItem("LongTimeString is " + dtCurrTime.ToLongTimeString());
}
public class FormTimeSpans : System.WinForms.Form

{
... as before

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com)

public FormTimeSpans()

{
//
// Required for Win Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

// constructor: TimeSpan(days, hours, minutes, seconds)
TimeSpan Span = new TimeSpan(4,2,15,0);

// initialize date to 1 Jan 2000, 12 pm
// constructor: DateTime(year,month,day,hours,minutes,seconds,
// milliseconds)
DateTime dtOld = new DateTime(2000,1,1,12,0,0,0);

DateTime dtNew = dtOld + Span;

AddItem("Original date was " + dtOld.ToLongDateString() +
" " + dtOld.ToShortTimeString());
AddItem("Adding time span of " + Span.ToString());
AddItem("Result is " + dtNew.ToLongDateString() + " " +
dtNew.ToShortTimeString());
AddItem("");
AddItem("Time span broken down is:");
AddItem("Days: " + Span.Days.ToString());
AddItem("Hours: " + Span.Hours.ToString());
AddItem("Minutes: " + Span.Minutes.ToString());
AddItem("Seconds: " + Span.Seconds.ToString());
AddItem("Milliseconds: " + Span.Milliseconds.ToString());
AddItem("Ticks: " + Span.Ticks.ToString());
AddItem("");
AddItem("TicksPerSecond: " + TimeSpan.TicksPerSecond.ToString());
AddItem("TicksPerHour: " + TimeSpan.TicksPerHour.ToString());


}

展开更多 50%)
分享

猜你喜欢

C#里操作时间的例子!

电脑网络
C#里操作时间的例子!

c#对xml的简单操作

Web开发
c#对xml的简单操作

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Visual C# 编程操作Excel

编程语言 网络编程
Visual C# 编程操作Excel

C#中操作Excel的方法(一)

电脑网络
C#中操作Excel的方法(一)

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

C#操作注册表的方法

编程语言 网络编程
C#操作注册表的方法

C# WORD操作实现代码

编程语言 网络编程
C# WORD操作实现代码

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Flash教程:打造雪花效果的三种方法

Flash教程:打造雪花效果的三种方法

FLASH中响应键盘事件的四种方法

FLASH中响应键盘事件的四种方法
下拉加载更多内容 ↓