范范(6)

2016-12-02 12:52:17来源:网络收集作者:一线码农人点击

第七城市

property VS index


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
interface Student
{
int this[int y,int m,int d]{get;set;}
}
class MyCalender
{
private int y, m, d;
public MyCalender()
{
}
public MyCalender(int _y,int _m,int _d)
{
y = _y;
m = _m;
d = _d;
}
public string DayOfWeek
{
get
{
System.DateTime dt = new DateTime(y, m, d);
return dt.DayOfWeek.ToString();
}
}
public bool IsLeapYear
{
get
{
if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0))
return true;
else
return false;
}
}
public string this[int year,int month,int day]
{
get
{
System.DateTime dt = new DateTime(year, month, day);
return dt.DayOfWeek.ToString();
}
}
}
class Program
{
static void Main(string[] args)
{
MyCalender mc = new MyCalender();
//Console.WriteLine(mc.DayOfWeek);
Console.WriteLine(mc[2016, 3, 25]);
Console.ReadLine();
}
}
}
http://www.cnblogs.com/ArmyShen/archive/2012/08/27/2659405.html

第七城市

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台