I have a collection of list of properties with key value pairs as follow screenshot in visual studio.
UPDATE:
I have the following screenshot if i expend the value(0) on the above screenshot.
How can I get a list (List (of string) may be?) with Key values from that?
For example, the new list will contain, {Id, Class Name, Forename, Surname, Dob}. No need to filter anything.
Many Thanks
If your list is a collection of KeyValue pairs then can you not just iterate this collection and build up a new list of strings representing the Key
Dim l2 As New List(Of String)
For Each kvp As KeyValuePair(Of String, String) In res(0)
l2.Add(kvp.Key)
Next
Here is an example. In this example, the key for each KeyValuePair is a String, but it might not always be, so there is an explicit .ToString() just in case the keys are another type.
Dim myList As New List(Of KeyValuePair(Of String, Object))
' add stuff to myList here
Dim keyList as List(Of String)
For Each item In myList
keyList.Add(item.Key.ToString())
Next item
EDIT: Try this:
' add stuff to myList here
Dim keyList as List(Of String)
For Each entry in res
For Each item In entry._values
keyList.Add(item.Key.ToString())
Next item
Next Entry
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.