首页 > 开发 > .Net > 正文

收集整理:C# .NET 函数列表

2020-02-03 15:51:16
字体:
来源:转载
供稿:网友

1、datetime 数字型 


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; (变量可用中文) 

2、int32.parse(变量) int32.parse("常量") 

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

3、 变量.tostring() 

字符型转换 转为字符串 

12345.tostring("n"); //生成 12,345.00 
12345.tostring("c"); //生成 ¥12,345.00 
12345.tostring("e"); //生成 1.234500e+004 
12345.tostring("f4"); //生成 12345.0000 
12345.tostring("x"); //生成 3039 (16进制) 

12345.tostring("p"); //生成 1,234,500.00% 

4、变量.length 数字型 

取字串长度:

如: string str="中国"; 
int len = str.length ; //len是自定义变量, str是求测的字串的变量名 

5、system.text.encoding.default.getbytes(变量) 

字码转换 转为比特码 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表