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(变量)
字码转换 转为比特码
新闻热点
疑难解答