`
raisun_1988
  • 浏览: 120131 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

Visual C#常用函数和方法集汇总(1)

    博客分类:
  • .Net
阅读更多

1DateTime 数字型

System.DateTime currentTime=new System.DateTime();

1.1 取当前年月日时分秒

currentTime=System.DateTime.Now;

1.2 取当前年

int =currentTime.Year;

1.3 取当前月

int =currentTime.Month;

1.4 取当前日

int =currentTime.Day;

1.5 取当前时

int =currentTime.Hour;

1.6 取当前分

int =currentTime.Minute;

1.7 取当前秒

int =currentTime.Second;

1.8 取当前毫秒

int 毫秒=currentTime.Millisecond;

(变量可用中文)

1.9 取中文日期显示——年月日时分

string strY=currentTime.ToString("f"); //不显示秒

1.10 取中文日期显示_年月

string strYM=currentTime.ToString("y");

1.11 取中文日期显示_月日

string strMD=currentTime.ToString("m");

1.12 取中文年月日

string strYMD=currentTime.ToString("D");

1.13 取当前时分,格式为:1424

string strT=currentTime.ToString("t");

1.14 取当前时间,格式为:<chsdate w:st="on" isrocdate="False" islunardate="False" day="23" month="9" year="2003"><span lang="EN-US" style="FONT-SIZE: 14pt; COLOR: navy; FONT-FAMILY: Arial; mso-font-kerning: 0pt; mso-fareast-language: ZH">2003-09-23</span></chsdate>T14:46:48

string strT=currentTime.ToString("s");

1.15 取当前时间,格式为:2003-09-23 14:48:30Z

string strT=currentTime.ToString("u");

1.16 取当前时间,格式为:2003-09-23 14:48

string strT=currentTime.ToString("g");

1.17 取当前时间,格式为:Tue, 23 Sep 2003 14:52:40 GMT

string strT=currentTime.ToString("r");

1.18获得当前时间 n 天后的日期时间

DateTime newDay = DateTime.Now.AddDays(100);

2Int32.Parse(变量) Int32.Parse("常量")

字符型转换 转为32位数字型

分享到:
评论

相关推荐

    Visual C#常用函数和方法集汇总(全)

    Visual C#常用函数和方法集汇总 本文汇总了 Visual C# 中常用的函数和方法,涵盖了日期时间处理、字符型转换、变量操作、字符串操作、用户 IP 地址获取等多方面的内容。 日期时间处理 1. 取当前年月日时分秒:...

    Visual C#常用函数和方法集汇总

    Visual C#常用函数和方法集汇总,做项目时常用的方法!!!!!

    \Visual C#常用函数和方法集汇总

    ### Visual C# 常用函数和方法集汇总解析 #### 一、日期与时间处理 **1. 获取当前时间** - **语法**: `System.DateTime currentTime = System.DateTime.Now;` - **描述**: 此行代码用于获取当前系统的时间,并将其...

    Visual+C#常用函数和方法集汇总

    "Visual C#常用函数和方法集汇总" Visual C#是一种功能强大且广泛应用的编程语言,它提供了许多实用的函数和方法来帮助开发者快速构建应用程序。下面是Visual C#常用函数和方法集汇总,涵盖日期型、字符型转换、...

    Visual C#常用函数的方法集汇总.txt

    ### Visual C# 常用函数的方法集汇总 在 C# 开发中,掌握常用的函数方法对于提高开发效率至关重要。本文将对给定文件中的标题、描述、标签以及部分内容进行详细解析,归纳总结出一系列实用的 C# 函数及其用法。 ##...

    Visual_C#_常用函数和方法集汇总

    在Visual C#编程中,掌握常用的函数和方法是至关重要的,因为它们可以帮助开发者高效地处理各种数据类型和任务。以下是一些关键知识点的详细说明: 1. **DateTime 类**: - `DateTime.Now` 返回当前系统的日期和...

    C#常用函数和方法集汇总

    在C#编程中,了解和熟练使用各种函数和方法对于编写高效、易维护的代码至关重要。以下是对给定标题和描述中的知识点的详细说明: 1. **DateTime 类型**: - `DateTime.Now`:获取当前系统的本地时间。 - `...

    C#常用第三方库引用dll文件合集

    总的来说,这个"C#常用第三方库引用dll文件合集"是C#开发者的重要资源,它涵盖了数据可视化、用户界面定制、数据库操作和二维码处理等多个方面,有助于提高开发效率并增强应用的功能性。合理利用这些库,可以使C#...

    c#知识集合,C#基本知识等

    `Visual C#常用函数和方法集汇总.txt`可能提供了这些功能的实例和解释。 6. **文件I/O操作**:C#提供了丰富的类库进行文件和目录操作,如`System.IO`命名空间下的`File`、`Directory`、`StreamReader`和`...

Global site tag (gtag.js) - Google Analytics