VCCodeEnum.AddMember(String, Object, Object) Method

Definition

Creates a new member code construct and inserts the code in the correct location.

EnvDTE::CodeVariable AddMember(std::wstring const & Name, winrt::Windows::Foundation::IInspectable const & Value, winrt::Windows::Foundation::IInspectable const & Position);
[System.Runtime.InteropServices.DispId(61)]
public EnvDTE.CodeVariable AddMember (string Name, object Value, object Position);
[<System.Runtime.InteropServices.DispId(61)>]
abstract member AddMember : string * obj * obj -> EnvDTE.CodeVariable
Public Function AddMember (Name As String, Optional Value As Object, Optional Position As Object) As CodeVariable

Parameters

Name
String

Required. The name of the new member.

Value
Object

Optional. The InitExpression of the CodeVariable object is returned. It can be passed in either as a string or as an expression object.

Position
Object

Optional. Default = 0. The code element after which to add the new element. If the value is a CodeElement, then the new element is added immediately after it.If the value is a Long data type, then AddMember(String, Object, Object) indicates the element after which to add the new element.Because collections begin their count at 1, passing 0 indicates that the new element should be placed at the beginning of the collection. A value of -1 means the element should be placed at the end.

Returns

A CodeVariable object.

Attributes

Remarks

AddMember adds a member to the enumeration and returns a CodeVariable object with IsConstant set to true.

When setting Value to a string, AddMember inserts any required syntax, such as equal signs or semicolons if the variable does not already have an initialization expression. Depending on the languages and any syntactic or semantic checks it performs on the passed-in string, setting this argument may fail. Languages are not required to check the string, and because the string is necessarily language-dependent, setting this argument could result in undefined behavior if the string has any ill-formed content.

When setting Value to a CodeElement, the decision as to whether the CodeElement must be newly created depends on the language implementation of the code model. Some languages may implement copying semantics if you pass in a code element that is already in a source file.

The correctness of the arguments is determined by the language behind the code model.

Applies to