Export (0) Print
Expand All

PortTypeCollection.Item Property (Int32)

Gets or sets the value of a PortType at the specified zero-based index.

Namespace:  System.Web.Services.Description
Assembly:  System.Web.Services (in System.Web.Services.dll)

public PortType this[
	int index
] { get; set; }

Parameters

index
Type: System.Int32

The zero-based index of the PortType whose value is modified or returned.

Property Value

Type: System.Web.Services.Description.PortType
A PortType.

ServiceDescription myServiceDescription = 
   ServiceDescription.Read("MathService_CS.wsdl");
PortTypeCollection myPortTypeCollection = 
   myServiceDescription.PortTypes;

int noOfPortTypes = myServiceDescription.PortTypes.Count;
Console.WriteLine("\nTotal number of PortTypes: " 
   + myServiceDescription.PortTypes.Count);

// Get the first PortType in the collection.
PortType myNewPortType = myPortTypeCollection[0];
Console.WriteLine(
   "The PortType at index 0 is: " + myNewPortType.Name);
Console.WriteLine("Removing the PortType " + myNewPortType.Name);

// Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType);

// Display the number of PortTypes.
Console.WriteLine("\nTotal number of PortTypes after removing: "
   + myServiceDescription.PortTypes.Count);

Console.WriteLine("Adding a PortType " + myNewPortType.Name);

// Add a new PortType from the collection.
myPortTypeCollection.Add(myNewPortType);

// Display the number of PortTypes after adding a port.
Console.WriteLine("Total number of PortTypes after " +
   "adding a new port: " + myServiceDescription.PortTypes.Count);

myServiceDescription.Write("MathService_New.wsdl");

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft