PortCollection.Item[] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定傳入參數所指定的 Port 執行個體。
多載
Item[Int32] |
取得或設定 Port 的值,於指定的以零起始的索引位置。 |
Item[String] |
取得由其名稱所指定的 Port。 |
Item[Int32]
取得或設定 Port 的值,於指定的以零起始的索引位置。
public:
property System::Web::Services::Description::Port ^ default[int] { System::Web::Services::Description::Port ^ get(int index); void set(int index, System::Web::Services::Description::Port ^ value); };
public System.Web.Services.Description.Port this[int index] { get; set; }
member this.Item(int) : System.Web.Services.Description.Port with get, set
Default Public Property Item(index As Integer) As Port
參數
屬性值
指定之索引處的通訊埠值。
範例
Service^ myService;
PortCollection^ myPortCollection;
ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathServiceItem_cs.wsdl" );
Console::WriteLine( "Total number of services : {0}", myServiceDescription->Services->Count );
for ( int i = 0; i < myServiceDescription->Services->Count; ++i )
{
myService = myServiceDescription->Services[ i ];
Console::WriteLine( "Name : {0}", 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[{0}] : {1}", i1, myPortCollection[ i1 ]->Name );
}
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);
}
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
適用於
Item[String]
取得由其名稱所指定的 Port。
public:
property System::Web::Services::Description::Port ^ default[System::String ^] { System::Web::Services::Description::Port ^ get(System::String ^ name); };
public System.Web.Services.Description.Port this[string name] { get; }
member this.Item(string) : System.Web.Services.Description.Port
Default Public ReadOnly Property Item(name As String) As Port
參數
屬性值
由其名稱指定的連接埠。
範例
Service^ myService;
PortCollection^ myPortCollection;
ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathServiceItem_cs.wsdl" );
Console::WriteLine( "Total number of services : {0}", myServiceDescription->Services->Count );
for ( int i = 0; i < myServiceDescription->Services->Count; ++i )
{
myService = myServiceDescription->Services[ i ];
Console::WriteLine( "Name : {0}", 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[{0}] : {1}", i1, myPortCollection[ i1 ]->Name );
}
String^ strPort = myPortCollection[ 0 ]->Name;
Port^ myPort = myPortCollection[ strPort ];
Console::WriteLine( "\nIndex of Port[{0}] : {1}", strPort, myPortCollection->IndexOf( myPort ) );
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));
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)