asp.net中常用方法和函数1、DateTime 数字型 
asp.net中常用方法和函数System.DateTime currentTime
=new System.DateTime(); 
asp.net中常用方法和函数
1.1 取当前年月日时分秒 
asp.net中常用方法和函数currentTime
=System.DateTime.Now; 
asp.net中常用方法和函数
1.2 取当前年 
asp.net中常用方法和函数
int 年=currentTime.Year; 
asp.net中常用方法和函数
1.3 取当前月 
asp.net中常用方法和函数
int 月=currentTime.Month; 
asp.net中常用方法和函数
1.4 取当前日 
asp.net中常用方法和函数
int 日=currentTime.Day; 
asp.net中常用方法和函数
1.5 取当前时 
asp.net中常用方法和函数
int 时=currentTime.Hour; 
asp.net中常用方法和函数
1.6 取当前分 
asp.net中常用方法和函数
int 分=currentTime.Minute; 
asp.net中常用方法和函数
1.7 取当前秒 
asp.net中常用方法和函数
int 秒=currentTime.Second; 
asp.net中常用方法和函数
1.8 取当前毫秒 
asp.net中常用方法和函数
int 毫秒=currentTime.Millisecond; 
asp.net中常用方法和函数(变量可用中文) 
asp.net中常用方法和函数
asp.net中常用方法和函数
1.9 取中文日期显示--年月日时分 
asp.net中常用方法和函数
string strY=currentTime.ToString("f"); //不显示秒 
asp.net中常用方法和函数

asp.net中常用方法和函数
1.10 取中文日期显示_年月 
asp.net中常用方法和函数
string strYM=currentTime.ToString("y"); 
asp.net中常用方法和函数
asp.net中常用方法和函数
1.11 取中文日期显示_月日 
asp.net中常用方法和函数
string strMD=currentTime.ToString("m"); 
asp.net中常用方法和函数
asp.net中常用方法和函数
1.12 取中文年月日 
asp.net中常用方法和函数
string strYMD=currentTime.ToString("D"); 
asp.net中常用方法和函数
asp.net中常用方法和函数
1.13 取当前时分,格式为:1424 
asp.net中常用方法和函数
string strT=currentTime.ToString("t"); 
asp.net中常用方法和函数
asp.net中常用方法和函数
1.14 取当前时间,格式为:2003-09-23T14:46:48 
asp.net中常用方法和函数
string strT=currentTime.ToString("s"); 
asp.net中常用方法和函数
asp.net中常用方法和函数
1.15 取当前时间,格式为:2003-09-23 14:48:30Z 
asp.net中常用方法和函数
string strT=currentTime.ToString("u"); 
asp.net中常用方法和函数
asp.net中常用方法和函数
1.16 取当前时间,格式为:2003-09-23 14:48 
asp.net中常用方法和函数
string strT=currentTime.ToString("g"); 
asp.net中常用方法和函数
asp.net中常用方法和函数
1.17 取当前时间,格式为:Tue, 23 Sep 2003 14:52:40 GMT 
asp.net中常用方法和函数
string strT=currentTime.ToString("r"); 
asp.net中常用方法和函数
asp.net中常用方法和函数
1.18获得当前时间 n 天后的日期时间 
asp.net中常用方法和函数DateTime newDay 
= DateTime.Now.AddDays(100); 
asp.net中常用方法和函数
asp.net中常用方法和函数
2、Int32.Parse(变量) Int32.Parse("常量"
asp.net中常用方法和函数字符型转换 转为32位数字型 
asp.net中常用方法和函数
asp.net中常用方法和函数
3、 变量.ToString() 
asp.net中常用方法和函数字符型转换 转为字符串 
asp.net中常用方法和函数
12345.ToString("n"); //生成 12,345.00 
asp.net中常用方法和函数
12345.ToString("C"); //生成 ¥12,345.00 
asp.net中常用方法和函数
12345.ToString("e"); //生成 1.234500e+004 
asp.net中常用方法和函数
12345.ToString("f4"); //生成 12345.0000 
asp.net中常用方法和函数
12345.ToString("x"); //生成 3039 (16进制) 
asp.net中常用方法和函数
12345.ToString("p"); //生成 1,234,500.00% 
asp.net中常用方法和函数

asp.net中常用方法和函数
asp.net中常用方法和函数
4、变量.Length 数字型 
asp.net中常用方法和函数取字串长度: 
asp.net中常用方法和函数如: 
string str="中国"
asp.net中常用方法和函数
int Len = str.Length ; //Len是自定义变量, str是求测的字串的变量名 
asp.net中常用方法和函数

asp.net中常用方法和函数
5、System.Text.Encoding.Default.GetBytes(变量) 
asp.net中常用方法和函数字码转换 转为比特码 
asp.net中常用方法和函数如:
byte[] bytStr = System.Text.Encoding.Default.GetBytes(str); 
asp.net中常用方法和函数然后可得到比特长度: 
asp.net中常用方法和函数len 
= bytStr.Length; 
asp.net中常用方法和函数
asp.net中常用方法和函数
6、System.Text.StringBuilder(""
asp.net中常用方法和函数字符串相加,(
+号是不是也一样?) 
asp.net中常用方法和函数如:System.Text.StringBuilder sb 
= new System.Text.StringBuilder(""); 
asp.net中常用方法和函数sb.Append(
"中华"); 
asp.net中常用方法和函数sb.Append(
"人民"); 
asp.net中常用方法和函数sb.Append(
"共和国"); 
asp.net中常用方法和函数
asp.net中常用方法和函数
7、变量.Substring(参数1,参数2); 
asp.net中常用方法和函数截取字串的一部分,参数1为左起始位数,参数2为截取几位。 
asp.net中常用方法和函数如:
string s1 = str.Substring(0,2); 
asp.net中常用方法和函数
asp.net中常用方法和函数
8、String user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString(); 
asp.net中常用方法和函数取远程用户IP地址 
asp.net中常用方法和函数
asp.net中常用方法和函数
9、穿过代理服务器取远程用户真实IP地址: 

相关文章:

  • 2021-12-28
  • 2022-12-23
  • 2021-08-27
  • 2021-07-28
  • 2021-09-14
猜你喜欢
  • 2022-01-24
  • 2021-10-14
  • 2021-07-23
  • 2022-12-23
  • 2022-02-04
  • 2021-07-29
相关资源
相似解决方案