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; (变量可用中文)
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% 【程序编程相关:EXCEL读取与写入数据的最佳方案(个人】
2.int32.parse(变量) int32.parse("常量") 字符型转换 转为32位数字型 【推荐阅读:DataGrid中加多选按钮 】
5.system.text.encoding.default.getbytes(变量) 字码转换 转为比特码 如:byte[] bytstr = system.text.encoding.default.getbytes(str); 然后可得到比特长度: len = bytstr.length; 【扩展信息:“身份证号”的数字分析 】
4.变量.length 数字型 取字串长度: 如: string str="中国"; int len = str.length ; //len是自定义变量, str是求测的字串的变量名
6.system.text.stringbuilder("") 字符串相加,(+号是不是也一样?) 如:system.text.stringbuilder sb = new system.text.stringbuilder(""); sb.append("中华"); sb.append("人民"); sb.append("共与国");
... 下一页