using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace test1 { class Program { static void Main(string[] args) { Console.WriteLine(Month); } private static int month = 7; public static int Month { get { return month; } set { if ((value > 0) && (value < 13)) { month = value; } } } } } 另外,按下Ctrl+K,再按Ctrl+F,即可实现VS的自动排版,但是不会去掉多余的空行。 有一个疑问:为什么必须是static才可以?