当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: 6. 避免使用输出参数原文引用:leG
 

 

    摘要:  在看dnn时发现了一个很酷的功能:能通过ie浏览器实现对zip文件的压缩和生成zip文件文件压缩包的功能。在仔细看过程序以后发现它是调用的sharpziplib.dll类库中的内容实现的压缩与解压功能。上网查了一下sharpziplib,发现它居然是开源的,在http://www.icsharpcode.net网站上有下。在网站里关于sharpziplib的源文件和调用演示包括帮助文档都有下,......
 ·通过.net访问 oracle数据库     »显示摘要«
    摘要:时间:2005-01-10 来源:不详   长期以来,我一直用的是 ms sql server / access 数据库,通过.net 访问ms自家的东西几乎没碰到过什么麻烦。最近项目中要用 oracle 作为数据库,学习研究了一些 .net 访问oracle 的东西,发现问题倒真的不少。 1。system.data.oracleclient 和 system.data.oledb 命名空间  虽......


[FxCop.设计规则]6. 避免使用输出参数
6.     避免使用输出参数

avoid out parameters 【程序编程相关:我的印度软件老师,给的 几个C# PRO

原文引用: 【推荐阅读:.net加密技术的应用(加密类代码参考)

【扩展信息:[VB.NET] Single & Do

typename:

avoidoutparameters

checkid:

ca1021

category:

microsoft.design

message level:

warning

certainty:

50%

breaking change:

breaking

cause: a public or protected method in a public type has an out parameter.

rule description

passing types by reference (using out or ref) requires experience with pointers, understanding how value types and reference types differ, and handling methods with multiple return values. also, the difference between out and ref parameters is not widely understood.

when a reference type is passed "by reference," the method intends to use the parameter to return a different instance of the object. (passing a reference type by reference is also known as using a double pointer, pointer to a pointer, or double indirection.) using the default calling convention, which is pass "by value," a parameter that takes a reference type already receives a pointer to the object. the pointer (not the object to which it points) is passed by value, meaning that the method cannot change the pointer to have it point to a new instance of the reference type, but can alter the contents of the object to which it points. for most applications this is sufficient and yields the desired behavior.

if a method needs to return a different instance, use the methods return value to accomplish this. see the asp?frame=false">system.string class for a wide variety of methods that operate on strings and return a new instance of a string. using this model, it is left to the caller to decide whether the original object is preserved.

while return values are commonplace and heavily used, the correct application of out and ref parameters requires intermediate design and coding skills. library architects designing for a general audience should not expect users to master working with out or ref parameters.

how to fix violations


...   下一页
    摘要:public function checkrow() as string dim row as integer = me.textbox1.selectionstart dim i as integer dim p as integer dim count as integer = 0 dim count1 as integer = 0 for i = 0 to me.textbox1.lines......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE