Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help translating one line of c# code...

Status
Not open for further replies.

OhioSteve

MIS
Joined
Mar 12, 2002
Messages
1,352
Location
US
I want to translate this line to vb.net:

Code:
pages=new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);


The know that the dictionary class is in System.Collections.generic in vb.

I can create that object in vb.net with this line:

Code:
Private pages As New Dictionary(Of String, String)

But I do NOT understand the last part of the c# fragment. I thought maybe the original author was casting the Dictionary to a StringComparer. But after researching it further, I don't think you CAN cast a Dictionary as a StringComparer. Plus, I think that to cast something in c# you put the new data type in FRONT of it, not behind it.

Please help!

 
Also its important to remember this:

New Dictionary(Of String, String) is not a constructor when you are dealing with generics. New Dictionary(Of String, String)() would be the default constructor (I think, I don't know VB.net that well).

The IEqualityComparer is just a parameter for one of yoru constructor overloads.

Hope it helps,

Alex

[small]----signature below----[/small]
Majority rule don't work in mental institutions

My Crummy Web Page
 
Code:
pages = New Dictionary(Of String, String)(StringComparer.InvariantCultureIgnoreCase)

It just specifies how the dictionary should be sorted

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top