简体   繁体   中英

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

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(...) ...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM