字符串,日期时间,读取-写入-计算 [英] String, DateTime, Read - Write - Calculate

查看:55
本文介绍了字符串,日期时间,读取-写入-计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将日期格式(如(05/03/2008 11:10:15 AM)以准确的格式"保存到文本文件.
从文本中读取它,然后将其作为日期时间值.
____________________________________________
如何找出哪个DateTime较大?

save a datetime like (05/03/2008 11:10:15 AM) "with the exact format" to a text file.
read it from the text then have it as a datetime value.
____________________________________________
how to find out which DateTime is bigger? how much bigger(e.g. date1 is 152 seconds bigger than date2)?

推荐答案

我们不为您做功课.那不是你学习的方式.我们在这里为您提供帮助,从长远来看不会伤害您.从长远来看,给您答案只会伤害您.当您的工作即将进行(或面试)时,您将来会做什么?试一下这个问题.尝试任何事物(任何事物),看看它是如何工作的.分解步骤并弄清楚每个步骤.如果您对代码有疑问(并且有代码示例),请回到此处.我们很乐于帮助您澄清问题.我们只是不会替您完成您的工作.
We don''t do your homework for you. That isn''t how you learn. We are here to help you, not hurt you in the long run. Giving you the answer would only hurt you in the long run. What are you going to do in the future, when your job is on the line (or your job interview)? Give this problem a shot. Try something (anything) and see how it works. Break down the steps and figure out how to do each one. Come back here if you have a question about the code (and you have a code sample). We are happy to help clarify things. We just won''t do your work for you.


要回答第一个问题:将运算符<><=>=DateTime一起使用操作数它们都定义正确.

要回答第二个问题:使用运算符"-"(减法),它返回类型为System.TimeSpan的值.

请参阅:
http://msdn.microsoft.com/en-us/library/system.datetime.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.timespan.aspx [ ^ ].

—SA
To answer first question: use the operators <, >, <= or >= with DateTime operands; they are all defined properly.

To answer the second question: use the operator ''-'' (subtraction), it returns the value of the type System.TimeSpan.

Please see:
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^],
http://msdn.microsoft.com/en-us/library/system.timespan.aspx[^].

—SA


这篇关于字符串,日期时间,读取-写入-计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆