月耳思进

人生在世如身处荆棘之中,心不动,人不妄动,不动则不伤;如心动则人妄动,伤其身痛其骨,于是体会到世间诸般痛苦。
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

[积累]c#.net常用函数

Posted on 2006-08-29 11:34  Xfan  阅读(170)  评论(0编辑  收藏  举报
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、  变量.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%

3、char.IsWhiteSpce(字串变量,位数)——逻辑型 
    查指定位置是否空字符; 
    如: 
    string str="中国  人民"; 
    Response.Write(char.IsWhiteSpace(str,2)); //结果为:True, 第一个字符是0位,2是第三个字符。

4、char.IsPunctuation('字符')  --逻辑型 
    查字符是否是标点符号 
   如:Response.Write(char.IsPunctuation('A'));   //返回:False