Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Visual Basic .NET hashTable, CType, and Rectangle confusion.

$
0
0

I don't understand what type is being converted here? CType(hEnum.Value, Rectangle).Height) are we converting to a hashtable, rectangle or string and integer or a combination of types? are we using a rectangle height for second argument?

Dim hTable AS New HashTable()

Dim r1 AS New Rectangle(1,1,10,10)

hTable.Add('R1', R1)

r1 = New Rectangle(2,2,20,20)

hTable.Add('R2',r1)

rTable.Add('R3', New Rectangle(3,3,2,2))

Dim Key AS Object

Dim R AS Rectangle

For Each Key In hTable.Keys

R = CType(hTable(Key),Rectangle)

Debug.WriteLine(String.Format('The area of Rectangle {0} is {1}' Key.ToString, R.Width * R.Height))

Next

Dim hEnum AS IDictionaryEnumerator

hEnum = hTable.GetEnumerator

While hEnum.MoveNext

Debug.WriteLine(String.Format('The area of rectangle ' & {0} is {1}, hEnum.Key, CType(hEnum.Value, Rectangle).Width * CType(hEnum.Value, Rectangle).Height))

End While


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>