Share via


CodeAttribute.Value 속성

개체의 데이터 값을 가져오거나 설정합니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
Property Value As String
string Value { get; set; }
property String^ Value {
    String^ get ();
    void set (String^ value);
}
abstract Value : string with get, set
function get Value () : String 
function set Value (value : String)

속성 값

형식: String
개체의 데이터 값을 나타내는 문자열입니다.

설명

특성이 name(someval, 2) 형식을 가지면 해당 값은 someval, 2가 됩니다.

참고

클래스, 구조체, 함수, 특성, 대리자 등의 코드 모델 요소를 특정한 방식으로 편집한 후에는 요소의 값이 명확하지 않을 수 있습니다. 즉, 요소의 값이 항상 같다고 할 수 없습니다.자세한 내용은 코드 모델을 사용하여 코드 검색(Visual Basic)의 "코드 모델 요소 값이 변경될 수 있음" 단원을 참조하십시오.

예제

Sub ValueExample(ByVal dte As DTE2)

    ' Before running this example, open a code document from a project
    ' and place the insertion point inside a class definition.
    Try
        ' Retrieve the CodeClass at the insertion point.
        Dim sel As TextSelection = _
            CType(dte.ActiveDocument.Selection, TextSelection)
        Dim cls As CodeClass = CType(sel.ActivePoint.CodeElement( _
            vsCMElement.vsCMElementClass), CodeClass)

        ' Enumerate the CodeClass's attributes.
        Dim attrs As String = ""
        Dim attr As CodeAttribute
        For Each attr In cls.Attributes
            attrs &= attr.Name & "(" & attr.Value & ")" & vbCrLf
        Next

        MsgBox(cls.Name & " has the following attributes:" & _
            vbCrLf & vbCrLf & attrs)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void ValueExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside a class definition.
    try
    {
        // Retrieve the CodeClass at the insertion point.
        TextSelection sel = 
            (TextSelection)dte.ActiveDocument.Selection;
        CodeClass cls = (CodeClass)sel.ActivePoint.get_CodeElement(
            vsCMElement.vsCMElementClass);

        // Enumerate the CodeClass's attributes.
        string attrs = "";
        foreach (CodeAttribute attr in cls.Attributes)
        {
            attrs += attr.Name + "(" + attr.Value + ")" + 
                Environment.NewLine;
        }

        MessageBox.Show(cls.Name + " has the following attributes:" + 
            Environment.NewLine + Environment.NewLine + attrs);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 보안

참고 항목

참조

CodeAttribute 인터페이스

EnvDTE 네임스페이스

기타 리소스

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행