Export (0) Print
Expand All

HttpWebRequest.GetHashCode Method

.NET Framework 1.1

Gets the hash code for this HttpWebRequest.

[Visual Basic]
Overrides Public Function GetHashCode() As Integer
[C#]
public override int GetHashCode();
[C++]
public: int GetHashCode();
[JScript]
public override function GetHashCode() : int;

Return Value

The hash code for the HttpWebRequest.

Remarks

The hash codes for HttpWebRequest A and B are guaranteed to be the same when A.Equals(B) is true.

This method implements the Object.GetHashCode.

Example

[Visual Basic, C#, C++] The following example uses the GetHashCode method to create a hash table.

[Visual Basic] 
' Create Uri object with the mentioned string.
Dim myUri As New Uri("http://www.contoso.com")
' Create three  'HttpWebRequest' objects with the  above Uri object.
Dim myHttpWebRequest1 As HttpWebRequest = CType(WebRequest.Create(myUri), HttpWebRequest)
Dim myHttpWebRequest2 As HttpWebRequest = CType(WebRequest.Create(myUri), HttpWebRequest)
Dim myHttpWebRequest3 As HttpWebRequest = CType(WebRequest.Create(myUri), HttpWebRequest)
' Create a 'Hashtable'.
Dim myTable As New Hashtable()
' Add the HashCodes of the three 'HttpWebRequest' objects to the table.
myTable.Add("HttpWebRequest1", myHttpWebRequest1.GetHashCode())
myTable.Add("HttpWebRequest2", myHttpWebRequest2.GetHashCode())
myTable.Add("HttpWebRequest3", myHttpWebRequest3.GetHashCode())

[C#] 
// Create Uri object with the mentioned string.
Uri myUri =new Uri("http://www.contoso.com");
// Create three  'HttpWebRequest' objects with the  above Uri object.
HttpWebRequest myHttpWebRequest1=(HttpWebRequest) WebRequest.Create(myUri);
HttpWebRequest myHttpWebRequest2=(HttpWebRequest) WebRequest.Create(myUri);
HttpWebRequest myHttpWebRequest3=(HttpWebRequest) WebRequest.Create(myUri);
// Create a 'Hashtable'.
Hashtable myTable= new Hashtable();
// Add the HashCodes of the three 'HttpWebRequest' objects to the table.
myTable.Add("HttpWebRequest1",myHttpWebRequest1.GetHashCode());
myTable.Add("HttpWebRequest2",myHttpWebRequest2.GetHashCode());
myTable.Add("HttpWebRequest3",myHttpWebRequest3.GetHashCode());

[C++] 
// Create Uri object with the mentioned string.
Uri* myUri = new Uri(S"http://www.contoso.com");

// Create three  'HttpWebRequest' objects with the  above Uri object.
HttpWebRequest* myHttpWebRequest1 =
   dynamic_cast<HttpWebRequest*> (WebRequest::Create(myUri));
HttpWebRequest* myHttpWebRequest2 =
   dynamic_cast<HttpWebRequest*> (WebRequest::Create(myUri));
HttpWebRequest* myHttpWebRequest3 =
   dynamic_cast<HttpWebRequest*> (WebRequest::Create(myUri));

// Create a 'Hashtable'.
Hashtable* myTable = new Hashtable();

// Add the HashCodes of the three 'HttpWebRequest' objects to the table.
myTable->Add(S"HttpWebRequest1", __box(myHttpWebRequest1->GetHashCode()));
myTable->Add(S"HttpWebRequest2", __box(myHttpWebRequest2->GetHashCode()));
myTable->Add(S"HttpWebRequest3", __box(myHttpWebRequest3->GetHashCode()));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

HttpWebRequest Class | HttpWebRequest Members | System.Net Namespace

Show:
© 2015 Microsoft