输入某年某月某日,判断这一天是这一年中的第几天。 输入某年某月某日,判断这一天是这一年中的第几天。 昨天面试的时候一个题目,我没什么好的方法,用的switch case,虚心求简单高效的方法。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { Console.WriteLine("请输入日期:"); string str = Console.ReadLine(); DateTime dt = new DateTime(); try { dt = DateTime.Parse(str); int year = dt.Year; DateTime dt0 = new DateTime(year, 1, 1); int days = (dt.Date - dt0.Date).Days + 1; Console.WriteLine(string.Format("天数是:{0}。",days.ToString())); } catch { Console.WriteLine("输入的日期格式不正确!"); } } }} (dt.Date - dt0.Date).Days + 1; new B(). DateTime today = DateTime.Now; DateTime firstDay = new DateTime(today.Year, 1, 1); return rst = (today-firstDay ).Days; select datediff(d,dateadd(yy,datediff(yy,0,@t),0),@t)(DateTime.Now-DateTime.Parse("2010-01-01")).Days 一段js代码 ASP.NET 编译后,运行的代码还是老的,修改的东西没有看到,这是什么原因? 能获得web.config 如何写一个页面能copy下数据文件来 当用Session给一个变量赋值后,这个变量不是一直存在的吗?(请高手赐教!) 关于强类型转换的问题 80分,请帮我看看这个Base是什么意思???在线,好了,立即给分。 ===为什么我用到GRIDVIEW的页面,引用母板页后就出错了?==== 小小问题,dbgrid不能更新? 请教一个关于XML的问题?(高手请进) 怎样加载.aspx? 统计在线用户问题 紧急呼救, 大家来帮帮忙吧
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入日期:");
string str = Console.ReadLine();
DateTime dt = new DateTime();
try
{
dt = DateTime.Parse(str);
int year = dt.Year;
DateTime dt0 = new DateTime(year, 1, 1);
int days = (dt.Date - dt0.Date).Days + 1;
Console.WriteLine(string.Format("天数是:{0}。",days.ToString()));
}
catch
{
Console.WriteLine("输入的日期格式不正确!");
}
}
}
}
new B().
DateTime today = DateTime.Now;
DateTime firstDay = new DateTime(today.Year, 1, 1);
return rst = (today-firstDay ).Days;
(DateTime.Now-DateTime.Parse("2010-01-01")).Days