Reputation: 349
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
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
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