当前位置:网站首页>unity和C#中怎么去比较2个日期大小
unity和C#中怎么去比较2个日期大小
2022-06-22 13:04:00 【苍狼王unity学院】
/// <summary>
/// 比较两个日期大小
/// </summary>
/// <param name="dateStr1">日期1</param>
/// <param name="dateStr2">日期2</param>
/// <param name="msg">返回信息</param>
public void CompanyDate(string dateStr1, string dateStr2,ref string msg) {
//将日期字符串转换为日期对象
DateTime t1 = Convert.ToDateTime(dateStr1);
DateTime t2 = Convert.ToDateTime(dateStr2);
//通过DateTIme.Compare()进行比较()
int compNum = DateTime.Compare(t1, t2);
//t1> t2
if (compNum > 0) {
msg = "t1:(" + dateStr1 + ")大于" + "t2(" + dateStr2 + ")";
}
//t1= t2
if (compNum == 0) {
msg = "t1:(" + dateStr1 + ")等于" + "t2(" + dateStr2 + ")";
}
//t1< t2
if (compNum < 0) {
msg = "t1:(" + dateStr1 + ")小于" + "t2(" + dateStr2 + ")";
}
}
边栏推荐
- “不敢去懷疑代碼,又不得不懷疑代碼”記一次網絡請求超時分析
- Do you know the scope and process of software project acceptance testing?
- 哈希索引设计发展史
- 成都测试设备开发_单片机C语言之数组介绍
- Consolidation of common functions of numpy Library
- How MySQL enables multiple auto incrementing columns in a table
- Are you familiar with redis cache of highly paid programmers & interview questions series 114? How are redis keys designed? Are you familiar with the memory obsolescence mechanism?
- 散户开户哪个证券公司好?手机开户安全么?
- Offline physical stores combined with VR panorama make virtual shopping more realistic
- BSN发展联盟理事长单志广:DDC可为中国元宇宙产业发展提供底层支撑
猜你喜欢

After several years of writing at CSDN, I published "the first book". Thank you!

Cve - 2022 - 22965 Resume

如何给VR全景作品添加遮罩?作用是什么?

Installing and using protobuf-c

《Kubernetes监控篇:Grafana通过自动化方式添加datasource和dashboard》

Kubernetes monitoring: grafana adds datasource and dashboard through automation

能让Jellyfin直接挂载阿里云盘的aliyundrive-fuse

Go Web 编程入门:验证器

别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!

hw在即,你还不会看危险报文?
随机推荐
能让Jellyfin直接挂载阿里云盘的aliyundrive-fuse
20 good habits of outstanding professionals
Number of times Oracle uses cursor to decompose numbers
如何理解fold change?倍数分析?
怎样在手机上开户?网上开户安全么?
Which securities company is good for retail investors to open an account? Is it safe to open a mobile account?
Eureka的InstanceInfoReplicator类(服务注册辅助类)
openGauss数据库源码解析系列文章—— 密态等值查询技术详解
什么是Bout?
“不敢去懷疑代碼,又不得不懷疑代碼”記一次網絡請求超時分析
位置编码(PE)是如何在Transformers中发挥作用的
SQL Server 常用函数
[Nacos cloud native] the first step of reading the source code is to start Nacos locally
《Kubernetes监控篇:Grafana通过自动化方式添加datasource和dashboard》
How many days are there between the two timestamps of PHP
transformers VIT图像模型向量获取
Chapter 1 overview of naturallanguageprocessing and deep learning
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
HMS Core新闻行业解决方案:让技术加上人文的温度
Shan Zhiguang, chairman of BSN Development Alliance: DDC can provide the underlying support for the development of China's meta universe industry