DateTimeDateTime.Now()DayOfWeek()
This is preliminary documentation and subject to change. 
Send feedback on this topic. 
Public Static (Shared) Fields
MaxValue A constant representing the largest possible value of DateTime. 
MinValue A constant representing the smallest possible value of DateTime. Public Static (Shared) Properties
Now Gets a DateTime that is the current local time on this computer. 
Today Gets the current date. 
UtcNow Gets a DateTime that is the current local time on this computer expressed as the coordinated universal time (UTC). Public Static (Shared) Methods
Compare Compares two instances of DateTime and returns an indication of their relative values. 
DaysInMonth Returns the number of days in the specified month of the specified year. 
Equals Overloaded. Returns a value indicating whether an instance of DateTime is equal to a specified object. 
FromFileTime Returns a DateTime equivalent to the specified operating system file timestamp. 
FromOADate Returns a DateTime equivalent to the specified OLE Automation Date. 
IsLeapYear Returns an indication whether the specified year is a leap year. 
Parse Overloaded. Converts the specified String representation of a date and time to its DateTime equivalent. 
ParseExact Overloaded. Converts the specified String representation of a date and time to its DateTime equivalent. The format of the String representation must match a specified format exactly. Public Static (Shared) Operators
Addition Operator Adds a specified time interval to a specified date and time, yielding a new date and time. 
Equality Operator Determines whether two specified instances of DateTime are equal. 
Greater Than Operator Determines whether one specified DateTime is greater than another specified DateTime. 
Greater Than Or Equal Operator Determines whether one specified DateTime is greater than or equal to another specified DateTime. 
Inequality Operator Determines whether two specified instances of DateTime are not equal. 
Less Than Operator Determines whether one specified DateTime is less than another specified DateTime. 
Less Than Or Equal Operator Determines whether one specified DateTime is less than or equal to another specified DateTime. 
Subtraction Operator Overloaded. Subtracts a specified DateTime or TimeSpan instance from a specified DateTime instance. Public Instance Constructors
DateTime Constructor Overloaded. Initializes a new instance of the DateTime structure. Public Instance Properties
Date Gets the date component of this instance. 
Day Gets the day of the month represented by this instance. 
DayOfWeek Gets the day of the week represented by this instance. 
DayOfYear Gets the day of the year represented by this instance. 
Hour Gets the hour component of the date represented by this instance. 
Millisecond Gets the milliseconds component of the date represented by this instance. 
Minute Gets the minute component of the date represented by this instance. 
Month Gets the month component of the date represented by this instance. 
Second Retrieves the seconds component of the date represented by this instance. 
Ticks Gets the number of 100-nanosecond ticks that represent the date and time of this instance. 
TimeOfDay Gets the time of day for this instance. 
Year Gets the year component of the date represented by this instance. Public Instance Methods
Add Adds the value of the specified TimeSpan instance to the value of this instance. 
AddDays Adds the specified number of days to the value of this instance. 
AddHours Adds the specified number of hours to the value of this instance. 
AddMilliseconds Adds the specified number of milliseconds to the value of this instance. 
AddMinutes Adds the specified number of minutes to the value of this instance. 
AddMonths Adds the specified number of months to the value of this instance. 
AddSeconds Adds the specified number of seconds to the value of this instance. 
AddTicks Adds the specified number of ticks to the value of this instance. 
AddYears Adds the specified number of years to the value of this instance. 
CompareTo Compares this instance to a specified object and returns an indication of their relative values. 
Equals Overloaded. Overridden. Returns a value indicating whether an instance of DateTime is equal to a specified object. 
GetDateTimeFormats Overloaded. Converts the value of this instance to all of the String representations supported by the standard DateTime format specifiers. 
GetHashCode Overridden. Returns the hash code for this instance. 
GetType (inherited from Object) Gets the Type of the current instance. 
GetTypeCode Returns the TypeCode for value type DateTime. 
Subtract Overloaded. Subtracts the specified time or duration from this instance. 
ToFileTime Converts the value of this instance to the format of the local system file time. 
ToLocalTime Converts the current coordinated universal time (UTC) to local time. 
ToLongDateString Converts the date denoted by this instance to its equivalent long date String representation. 
ToLongTimeString Converts the time denoted by this instance to its equivalent long time String representation. 
ToOADate Converts the value of this instance to the equivalent OLE Automation date. 
ToShortDateString Converts the date denoted by this instance to its equivalent short date String representation. 
ToShortTimeString Converts the time denoted by this instance to its equivalent short time String representation. 
ToString Overloaded. Overridden. Converts the value of this instance to its equivalent String representation. 
ToUniversalTime Converts the current local time to coordinated universal time (UTC). Protected Instance Methods
Finalize (inherited from Object) Overridden. Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. 
In C# and C++, finalizers are expressed using destructor syntax.
 
MemberwiseClone (inherited from Object) Creates a shallow copy of the current Object. 

解决方案 »

  1.   

    ripper(rIPPER)老兄,能给出个例子吗,不胜感激 
      

  2.   

    这个很简单的,应该自己试试DateTime dt=new DateTime.Now();
    …………
    …………
    return dt.DayofWeek().ToString();
      

  3.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace datatime
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Label label2;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent(); //
    // TODO: Add any constructor code after InitializeComponent call
    //
    } /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.label1 = new System.Windows.Forms.Label();
    this.button1 = new System.Windows.Forms.Button();
    this.label2 = new System.Windows.Forms.Label();
    this.SuspendLayout();
    // 
    // label1
    // 
    this.label1.Location = new System.Drawing.Point(32, 32);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(184, 24);
    this.label1.TabIndex = 0;
    this.label1.Text = "label1";
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(80, 128);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(192, 32);
    this.button1.TabIndex = 1;
    this.button1.Text = "button1";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // label2
    // 
    this.label2.Location = new System.Drawing.Point(32, 64);
    this.label2.Name = "label2";
    this.label2.Size = new System.Drawing.Size(184, 32);
    this.label2.TabIndex = 2;
    this.label2.Text = "label2";
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.label2,
      this.button1,
      this.label1});
    this.Name = "Form1";
    this.Text = "Form1";
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void button1_Click(object sender, System.EventArgs e)
    {

    label1.Text=DateTime.Now.ToString();
    DateTime d1=new DateTime(2001,10,20,20,8,1);
    label2.Text="day:" + d1.Day.ToString() + "week: " +d1.DayOfWeek.ToString(); }
    }
    }/*
    label1.Text=DateTime.Now.ToString();
    DateTime d1=new DateTime(2001,10,20,20,8,1);
    label2.Text="day:" + d1.Day.ToString() + "week: " +d1.DayOfWeek.ToString();
    DateTime 对象。
    DayOfWek得到星期几的。