渡されたパラメータによって指定された Port インスタンスを取得または設定します。
[C#] C# では、このプロパティは PortCollection クラスのインデクサになります。
オーバーロードの一覧
指定の 0 から始まるインデックス番号に対応する Port の値を取得または設定します。
[Visual Basic] Overloads Public Default Property Item(Integer) As Port
[C++] public: __property Port* get_Item(int);
public: __property void set_Item(int, Port*);
[JScript] PortCollection.Item (int)
Name プロパティによって指定された Port を取得します。
[Visual Basic] Overloads Public Default ReadOnly Property Item(String) As Port
[JScript] PortCollection.Item (String)
使用例
[Visual Basic, C#, C++] メモ ここでは、Item プロパティ (PortCollection インデクサ) のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。
Dim myService As Service
Dim myPortCollection As PortCollection
Dim myServiceDescription As ServiceDescription = _
ServiceDescription.Read("MathServiceItem_vb.wsdl")
Console.WriteLine("Total number of services : " & _
myServiceDescription.Services.Count.ToString)
Dim i As Integer
For i = 0 to myServiceDescription.Services.Count - 1
myService = myServiceDescription.Services(i)
Console.WriteLine("Name : " & myService.Name)
myPortCollection = myService.Ports
' Create an array of ports.
Console.WriteLine(ControlChars.NewLine & "Port collection :")
Dim i1 As Integer
For i1 = 0 to myService.Ports.Count - 1
Console.WriteLine("Port[" & i1.ToString & "] : " & _
myPortCollection(i1).Name)
Next
Dim strPort As String = myPortCollection(0).Name
Dim myPort As Port = myPortCollection(strPort)
Console.WriteLine(ControlChars.NewLine & _
"Index of Port[" & strPort & "] : " & _
myPortCollection.IndexOf(myPort).ToString)
[C#]
Service myService;
PortCollection myPortCollection;
ServiceDescription myServiceDescription =
ServiceDescription.Read("MathServiceItem_cs.wsdl");
Console.WriteLine("Total number of services : "
+ myServiceDescription.Services.Count);
for(int i=0; i < myServiceDescription.Services.Count; ++i)
{
myService = myServiceDescription.Services[i];
Console.WriteLine("Name : " + myService.Name);
myPortCollection = myService.Ports;
// Create an array of ports.
Console.WriteLine("\nPort collection :");
for(int i1=0 ; i1 < myService.Ports.Count ; ++i1)
{
Console.WriteLine("Port[" + i1+"] : " +
myPortCollection[i1].Name);
}
string strPort = myPortCollection[0].Name;
Port myPort = myPortCollection[strPort];
Console.WriteLine("\nIndex of Port[" + strPort + "] : " +
myPortCollection.IndexOf(myPort));
[C++]
Service* myService;
PortCollection* myPortCollection;
ServiceDescription* myServiceDescription =
ServiceDescription::Read(S"MathServiceItem_cs.wsdl");
Console::WriteLine(S"Total number of services : {0}", __box(myServiceDescription->Services->Count));
for(int i=0; i < myServiceDescription->Services->Count; ++i)
{
myService = myServiceDescription->Services->Item[i];
Console::WriteLine(S"Name : {0}", myService->Name);
myPortCollection = myService->Ports;
// Create an array of ports.
Console::WriteLine(S"\nPort collection :");
for(int i1=0 ; i1 < myService->Ports->Count ; ++i1)
{
Console::WriteLine(S"Port[{0}] : {1}", __box(i1), myPortCollection->Item[i1]->Name);
}
String* strPort = myPortCollection->Item[0]->Name;
Port* myPort = myPortCollection->Item[strPort];
Console::WriteLine(S"\nIndex of Port[{0}] : {1}", strPort, __box(myPortCollection->IndexOf(myPort)));
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
参照
PortCollection クラス | PortCollection メンバ | System.Web.Services.Description 名前空間