摘要:
在程序中经常碰到时间,或是数字类型信息,这些字段在数据库中可以为空,但是时间和数字等值类型都必须要求有值。可空类型顾名思义类型可以为空,它使得值类型可以为空,定义型如className?,例如时间的可空类型为DateTime?。将String类型转换成DateTime? 1 private DateTime? GetNullableDateTime(string str) 2 { 3 return string.IsNullOrEmpty(str) ? null : 4 (DateTime?)Convert.ToDateTime(str)... 阅读全文
posted @ 2012-09-25 02:13
itprobie-菜鸟程序员
阅读(349)
评论(0)
推荐(0)
摘要:
字符串扩展方法 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 6 using System.Text; 7 8 public static class StringExtend 9 {10 public static DateTime ToDatetime(this string str)11 {12 if (string.IsNullOrEmpty(str))13 return DateTi... 阅读全文
posted @ 2012-09-25 01:53
itprobie-菜鸟程序员
阅读(412)
评论(0)
推荐(0)
摘要:
页面中获取url参数,一便其他的方法调用1>通过属性获取,将url参数封装到属性中统一调用。1 public string Id { get { return Request.QueryString["id"]; } }2>通过方法获取,将url参数封装到方法中,作为方法的结果返回。1 protected string GetUrlId()2 {3 return Request.QueryString["id"];4 }3>通过字段获取,字段一 个字段,在页面的page_load事件中初始化url参数的值给该字段 1 public st 阅读全文
posted @ 2012-09-25 00:18
itprobie-菜鸟程序员
阅读(3664)
评论(0)
推荐(0)
浙公网安备 33010602011771号