共用方式為


CodeAttributeDeclarationCollection.Add(CodeAttributeDeclaration) 方法

定義

將具有指定值的 CodeAttributeDeclaration 物件加入至集合。

public:
 int Add(System::CodeDom::CodeAttributeDeclaration ^ value);
public int Add (System.CodeDom.CodeAttributeDeclaration value);
member this.Add : System.CodeDom.CodeAttributeDeclaration -> int
Public Function Add (value As CodeAttributeDeclaration) As Integer

參數

value
CodeAttributeDeclaration

要加入的 CodeAttributeDeclaration 物件。

傳回

要插入新項目的索引。

範例

下列範例示範如何將 物件新增 CodeAttributeDeclarationCodeAttributeDeclarationCollection 實例。

// Adds a CodeAttributeDeclaration to the collection.
array<CodeAttributeArgument^>^temp = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )};
collection->Add( gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp ) );
// Adds a CodeAttributeDeclaration to the collection.
collection.Add( new CodeAttributeDeclaration("DescriptionAttribute",  new CodeAttributeArgument(new CodePrimitiveExpression("Test Description"))) );
' Adds a CodeAttributeDeclaration to the collection.
collection.Add(New CodeAttributeDeclaration("DescriptionAttribute", New CodeAttributeArgument(New CodePrimitiveExpression("Test Description"))))

適用於

另請參閱