摘要: Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE MicrosoftInternetExplorer4 操作自定义配置节 摘要:在网站设计上,经常使用Web.Config文件解耦合。例如通过配置文件确定实例化哪个工厂,得到不同的数据访问层。这就需要一个灵活的操作配置文件的机制。鄙人在学习过程中,将知识记下。 相关知识点: 1. Co...阅读全文
posted @ 2009-07-10 16:19 gecko 阅读(291) 评论(0) 编辑

首先提个问题:is关键字是编译器决定,还是运行时决定?

 

is :检查对象是否与给定类型兼容。

如果所提供的表达式非空,并且所提供的对象可以强制转换为所提供的类型而不会导致引发异常,则 is 表达式的计算结果将是 true

如果已知表达式将始终是 true 或始终是 false,则 is 关键字将导致编译时警告,但是,通常在运行时才计算类型兼容性。

不能重载 is 运算符。

请注意,is 运算符只考虑引用转换、装箱转换和取消装箱转换。不考虑其他转换,如用户定义的转换。

is 运算符的左侧不允许使用匿名方法。lambda 表达式属于例外。

 

as

as 运算符用于在兼容的引用类型之间执行转换。

as 运算符类似于强制转换操作。但是,如果无法进行转换,则 as 返回 null 而非引发异常。

 

除上面MS官方所说之外,通过IL,我们可以看出,用is表达式生成的语句更为简洁。

比如类型判等:

if (s is father)
{
    f 
= s as mother;
}

 生成的IL代码如下  :

Code

使用typeof和GetType()

if (s.GetType() == typeof(father))
{
     f 
= s as mother;
}

 生成IL如下:

Code

显然执行效率上is快了。

 

 

posted @ 2009-06-19 16:03 gecko 阅读(58) 评论(1) 编辑

故事:

联合利华引进了一条香皂包装生产线,结果发现这条生产线有个缺陷:常常会有盒子里没装入香皂。总不能把空盒子卖给顾客啊,他们只得请了一个学自动化的博士后设计一个方案来分拣空的香皂盒。博士后拉起了一个十几人的科研攻关小组,综合采用了机械、微电子、自动化、X射线探测等技术,花了几十万,解决了问题。每当生产线上有空香皂盒通过,两旁的探测器会检测到,并且驱动一只机械手把空皂盒推走。  中国南方有个乡镇企业也买了同样的生产线,老板发现这个问题后大为发火,找了个小工来说:“你他妈给老子把这个搞定,不然你给老子爬走。”


小工很快想出了办法:他花了90块钱在生产线旁边放了一台大功率电风扇猛吹,于是空皂盒都被吹走了。


心得:

一个体现在特定场景的问题,博士后寻求解决问题的通用性。
小作坊虽然快捷,相同问题,在数据(如重量)产生变化时则行不通。
这个问题也体现在了软件开发上,一个好的企业拥有好的架构就应该如联合利华一般去做。效益表现在后期的劳动付出上。
而南方乡镇企业的规模和性质,也注定他解决问题的局限性。但能解决目前问题就是他们最需要的。
我们要是做小软件作坊,在一定程度上是需要南方乡镇企业的变通方式。同时在时间和精力及阅历允许的情况下,寻求解决问题的通用性,产生的效益是不同的。
这样,我便觉得是小作坊寻求开发模式突破的一个方式。也是小作坊走向联合利华能花钱的一个途径吧。

posted @ 2009-06-10 09:43 gecko 阅读(113) 评论(0) 编辑
写程序的时候突然忘了C#的控件命名的大小写的规范,去网上找了些资料,拷过来看看。
Standard Control

类 型 前 缀 示 例
Adrotator adrt adrtTopAd
BulletedList blst blstCity
Button btn btnSubmit
Calendar cal calMettingDates
CheckBox chk chkBlue
CheckBoxList chkl chklFavColors
DropDownList drop dropCountries
FileUpLoad fup fupImage
HiddenField hfld hfldName
HyperLink hlk hlkDetails
Image img imgAuntBetty
ImageButton ibtn ibtnSubmit
ImageMap imap imapSite
Label lbl lblResults
LinkButton lbtn lbtnSubmit
ListBox lst lstCountries
Literal ltl ltlTitle
Localize loc locChina
MultiView mvw mvwForm1
Panel pnl pnlForm2
PlaceHolder plh plhFormContents
RadioButton rad radFemale
RadioButtonList radl radlGender
SubStitution subs subsTime
Table tbl tblCountryCodes
TextBox txt txtFirstName
View vw vwCity
Wizard wiz wizRegister
Xml xml xmlBooks

Data Control

类 型 前 缀 示 例
AccessDataSource ads adsPubs
DataList dlst dlstTitles
DetailView dvw dvwTitles
FormView fvw fvwFonts
GridView gvw gvwCity
ObjectDataSource ods odsMenus
Repeater rpt rptQueryResults
ReportViewer rvw rvwRecord
SiteMapDataSource smds smdsSite
SqlDataSource sds sdsBooks
XmlDataSource xds xdsTitles

Validation Control

类 型 前 缀 示 例
CompareValidator valc valcValidAge
CustomValidator valx valxDBCheck
RangeValidator valg valgAge
RegularExpressionValidator vale valeEmail
RequiredFieldValidator valr valrFirstName
ValidationSummary vals valsFormErrors

Navigation Control

类 型 前 缀 示 例
Menu mnu mnuUser1
SiteMapPath smp smpSite1
TreeView trvw trvwMenu

Login Control

类 型 前 缀 示 例
ChangePassword cpwd cpwdUser1
CreateUserWizard cuw cuwLogin
Login log logCenter
LoginName logn lognUser
LoginStatus logs logsUser
LoginView logv logvUser
PasswordRecovery pwdr pwdrUser

WebParts Control

类 型 前 缀 示 例
AppearanceEditorPart paed paedPart1
BehaviorEditorPart pbed pbedPart2
CatalogZone zca zcatCity
ConnectionsZone zcon zconDataBase
DeclarativeCatalogPart pdca pdcaPart1
EditorZone zed zedNews
ImportCatalogPart pica picaPart
LayoutEditorPart pled pledNews
PageCatalogPart ppca ppcaMail
PropertyGridEditorPart ppge ppgeServer
ProxyWebPartManager mpwp mpwpWeb
WebPartManager mwp mwpSite1
WebPartZone zwp zwpSite2

 

補充:

  Control   type prefix Example  
  Animated   button ani aniMailBox  
  Button btn  
  Check   box chk chkReadOnly  
  ColorDialog clrdlg  
  Combo   box,   drop-down   list   box cbo cboEnglish  
  Communications   com comFax  
  ContextMenu ctxmnu  
  Control   (used   within   procedures   when   the   specific   type   is   unknown) ctr ctrCurrent  
  CrystalReportViewer crvw  
  Data dat datBiblio  
  Data   grid dgd dgdTitles  
  Data   list dbl dblPublisher  
  Data   repeater drp drpLocation  
  Data-bound   combo   box dbcbo dbcboLanguage  
  Data-bound   grid dbgrd dbgrdQueryResult  
  Data-bound   list   box dblst dblstJobType  
  Datetime   picker dtp dtpPublished  
  Directory   list   box dir dirSource  
  DomainUpDown dupd  
  Drive   list   box drv drvTarget  
  ErrorProvider err  
  File   list   box fil filSource  
  Flat   scroll   bar fsb fsbMove  
  FontDialog fntdlg  
  Form frm frmEntry  
  Frame fra fraLanguage  
  Gauge gau gauStatus  
  Graph gra graRevenue  
  Grid grd grdPrices  
  GroupBox grp  
  HelpProvider hlp  
  Hierarchical   flexgrid flex flexOrders  
  HScroll   bar hsb hsbVolume  
  Image img imgIcon  
  Image   combo imgcbo imgcboProduct  
  ImageList ils ilsAllIcons  
  Label lbl lblHelpMessage  
  Line lin linVertical  
  LinkLabel lnk  
  Listbox lst lstPolicyCodes  
  ListView lvw lvwHeadings  
  MAPI   message mpm mpmSentMessage  
  MAPI   session mps mpsSession  
  MCI mci mciVideo  
  Menu mnu mnuFileOpen  
  Month   view mvw mvwPeriod  
  MonthCalendar mcl  
  MS   Chart ch chSalesbyRegion  
  MS   Flex   grid msg msgClients  
  MS   Tab   mst mstFirst  
  NotifyIcon nti  
  NumericUpDown nupd  
  OLE   container ole oleWorksheet  
  OpenFileDialog ofdlg  
  PageSetUpDialog psdlg  
  Picture   box pic picVGA  
  Picture   clip clp clpToolbar  
  PrintDocument prndoc  
  PrintPreviewControl ppctl  
  PrintPreviewDialog ppdlg  
  ProgressBar prg prgLoadFile  
  RadioButton rbtn  
  Remote   Data rd rdTitles  
  RichTextBox rtf rtfReport  
  SaveFileDialog sfdlg  
  Shape shp shpCircle  
  Slider sld sldScale  
  Spin spn spnPages  
  Splitter spt  
  StatusBar sta staDateTime  
  SysInfo sys sysMonitor  
  TabContrl tab  
  TabStrip tab tabOptions  
  Text   box txt txtLastName  
  Timer tmr tmrAlarm  
  Toolbar tlb tlbActions  
  TrackBar trb  
  TreeView tre treOrganization  
  UpDown upd updDirection  
  VScroll   bar vsb vsbRate 

posted @ 2009-05-06 16:56 gecko 阅读(189) 评论(0) 编辑
在 ASP.NET 页面的寿命周期内,Page 对象会公开一些被频繁使用的标准事件。ASP.NET 页面框架在运行时,会自动连接到(连线)这些方法的相应代理实例。这样您就无须编写必要的“粘接代码”。以下列表按激发顺序提供运行时连线的代理实例:
• Page_Init:出现此事件期间,您可以初始化值或连接可能具有的任何事件处理程序。
• Page_Load:出现此事件期间,您可以执行一系列的操作来首次创建 ASP.NET 页面或响应由投递引起的客户端事件。在此事件之前,已还原页面和控件视图状态。使用 IsPostBack 页面属性检查是否为首次处理该页面。如果是首次处理,请执行数据绑定。此外,请读取并更新控件属性。
• Page_DataBind:在页面级别调用 DataBind 方法时,将引发 DataBind 事件。如果在单个控件上调用 DataBind,则它只激发它下面控件的 DataBind 事件。
• Page_PreRender:恰好在保存视图状态和呈现控件之前激发 PreRender 事件。您可以使用此事件在控件上执行所有最后时刻操作。
• Page_Unload:完成页面呈现之后,将激发 Page_Unload 事件。此事件是执行最终清理工作的合适位置。这包括清理打开的数据库连接、丢弃对象或关闭打开的文件等操作。
以下列表概括了非确定性事件。 • Page_Error:如果在页面处理过程中出现未处理的例外,则激发 Error 事件。错误事件为您提供了妥善处理错误的机会。
• Page_AbortTransaction:如果要指明交易是成功还是失败,交易事件非常有用。此事件通常用于购物车方案,其中此事件可以指示订购是成功还是失败。如果已终止交易,则激发此事件。
• Page_CommitTransaction:如果已成功提交交易,则激发此事件。
http://www.cnblogs.com/hide0511/archive/2006/08/30/490783.html
posted @ 2009-05-06 16:44 gecko 阅读(177) 评论(0) 编辑

 

安装时出项了这个错误,重装windows installer 4.5后成功解决.

posted @ 2009-04-21 10:08 gecko 阅读(74) 评论(0) 编辑
摘要: 项目需要,要用sybase数据库. 当作一次学习点点滴滴记下来.sybase中字段缺省值查看以及修改如果没有sybase central(或者由于字符集原因无法看到表的ddl语句的时候)或者rapid sql等工具的情况下可以使用isql或者sql advantage登录.sp_help table_name.看到某个字段的default_name对应为"表名_数字"select text fro...阅读全文
posted @ 2008-11-13 16:49 gecko 阅读(772) 评论(0) 编辑
摘要: PlatformInvokeMethodsdefinedinanativeDLLmaybeinvokedusingthePInvoke(platforminvoke)functionalityoftheCLR.PInvokewillhandleeverythingneededtomakethecallwork.Itwillautomaticallyswitchfrommanagedtounmana...阅读全文
posted @ 2008-09-29 13:35 gecko 阅读(235) 评论(0) 编辑
摘要: 怎么选择都是对的! 这两天被安排到广州做事,兼职没去做,少赚一百块~~~。对于这次新的项目也所知无几。不过,刚刚在一个同学的日志上,无意看到他的日志中提及要被安排到广州两个月开发新项目。很明显说的项目都是跟我同一个,惊讶的的是,两个月。两个月后,我也就差不多毕业了! “最近很煩惱.因為身上已經沒多少錢了. 在我走投無路的時候學校卻給了我一份差事.就去做一個項目.但是工作地方在廣州.工期...阅读全文
posted @ 2008-09-12 07:46 gecko 阅读(1957) 评论(21) 编辑
摘要: [代码]阅读全文
posted @ 2008-08-18 17:02 gecko 阅读(95) 评论(0) 编辑