次の方法で共有


Properties.Item メソッド

Properties コレクションのインデックス付きメンバーを返します。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
Function Item ( _
    index As Object _
) As Property
Property Item(
    Object index
)
Property^ Item(
    [InAttribute] Object^ index
)
abstract Item : 
        index:Object -> Property 
function Item(
    index : Object
) : Property

パラメーター

  • index
    型: System.Object
    必ず指定します。返される Property オブジェクトのインデックス。

戻り値

型: EnvDTE.Property
Property オブジェクト。

解説

Index に渡される値は、Properties コレクション内の Property オブジェクトへのインデックス値、またはコレクション内の Property オブジェクトの名前です。

指定した値がコレクションで見つからない場合、Item メソッドは、ArgumentException 例外をスローします。

public void CodeExample(DTE2 dte)
{  
    try
    {   // Open a solution before running this example
        Properties props = dte.Solution.Properties;
        Property prop;
        string msg;
        msg = "How many properties are there in the current solution: " + props.Count.ToString();
        msg += "\nThe application containing this Properties collection is " + props.DTE.Name;
        msg += "\nThe parent object of the Properties collection is a " + ((Solution)props.Parent).FullName;
        msg += "\nThe application property returns : " + ((DTE2)props.Application).Name;
        if (props.Count > 0)
        {
            prop = props.Item(1);
            msg += "\nThe first Property in the Properties collection is " + prop.Name;
        }
        MessageBox.Show(msg);
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

Properties インターフェイス

EnvDTE 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する