
本站地址:http://www.bajiao123.com

[FxCop.设计规则]6. 避免使用输出参数
The following example library illustrates how ref parameters for reference types are used, and shows a better way to implement this functionality.
[C#]
using System;namespace DesignLibrary{ public class ReferenceTypesAndParameters {
// The following syntax will not work. You cannot make a // reference type that is passed by value point to a new // instance. This needs the ref keyword.
public static void BadPassTheObject(string argument) { argument = argument + " ABCDE"; }
// The following syntax will work, but is considered bad design. // It reassigns the argument to point to a new instance of string. // Violates rule DoNotPassTypesByReference.
public static void PassTheReference(ref string argument) { argument = argument + " ABCDE&quo
<< 上一页 [11] [12] [13] [14] [15] 下一页
本站地址:http://www.bajiao123.com

