C#获取本周五日期字符串
2017-01-12 15:12
316 查看
1 using System; 2 using System.Collections.Generic; 3 using System.Globalization; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7 8 namespace Demo 9 { 10 class Program 11 { 12 static void Main(string[] args) 13 { 14 string FriStr = GetDateOfDayInWeek(DateTime.Now, DayOfWeek.Friday); 15 Console.WriteLine(FriStr); 16 Console.ReadKey(); 17 } 18 19 static string GetDateOfDayInWeek(DateTime dt, DayOfWeek dw) 20 { 21 DateTime date = dt.AddDays(dw - dt.DayOfWeek); 22 //具体显示格式参见:https://msdn.microsoft.com/zh-cn/library/8tfzyc64.aspx 23 return date.ToString("dd MMMM yyyy", DateTimeFormatInfo.InvariantInfo); 24 } 25 } 26 }
更多日期显示格式参照:http://www.cnblogs.com/ATree/archive/2010/06/06/CSharp-DateTime-Tostring-LongDatePattern.html
相关文章推荐
- c#清空文本文件
- c# serialize
- C# 多线程下 静态类字段异常
- C# 关键字const与readonly的区别
- C# using三种使用方法
- C# 5.0五大新特性
- C# 5.0五大新特性
- C#设计模式(5)——建造者模式
- C# Hadoop学习笔记(一)—环境安装
- C# socket编程实践——支持广播的简单socket服务器
- C#6.0中10大新特性的应用和总结
- c#之位数组学习笔记
- c# 实现WebSocket
- C# 可空类型(Nullable)
- c# GDI+ 中发生一般性错误。。
- C# 字符串格式化
- c#中超级好用的DataSet
- c#读取txt文件并生成一张表
- c#接口
- c#