ziad mansour
ziad mansour

Reputation: 349

convert function operator from c# into vb.net

How convert function operator from c# into vb.net,
If i have this code:

Dictionary<string, string> sd = new Dictionary<string, string>();
string sKey = sd.Single(kvp => kvp.Value.Equals("A value")).Key;

how to convert it to vb.net?
I am trying to get the Key name from a dictionary list

Upvotes: 0

Views: 88

Answers (2)

daro
daro

Reputation: 313

Carsten already answered you, but with these conversion problems you can always look at this online conversion tool.

For your code the tool gives:

Dim sd As New Dictionary(Of String, String)()
Dim sKey As String = sd.[Single](Function(kvp) kvp.Value.Equals("A value")).Key

Upvotes: 0

Random Dev
Random Dev

Reputation: 52280

this one should do

dim sd as new Dictionary(of string, string)()
dim sKey = sd.Single(function(kvp) kvp.Value.Equals("A value")).Key

as you can see it's basically just adding dim (usually instead of var), removing the ;, changing <...> into (of ...) and => into function(...) ...

Upvotes: 2

Related Questions