Tell me how modern means to quickly find the desired object in the List

There is a List(Of ExDatabase)

It is known that in the DataBase property of one of the objects in the list there is for example “databaseTest”. How quickly (in one line, if possible) to get the object itself?

ExDatabase Class ExDatabase

 Imports MySql.Data.MySqlClient Imports System.ComponentModel.TypeConverter Imports System.ComponentModel Imports System.Drawing.Design <Serializable()> Public Class ExDatabase Public Sub New() End Sub Private _database As String <DisplayName("Имя базы")> <TypeConverter(GetType(DatabaseListConverter))> Public Property DataBase() As String Get Return _database End Get Set(ByVal value As String) _database = value End Set End Property Private _table_prefix As String <DisplayName("Префикс таблиц")> Public Property TablePrefix() As String Get Return _table_prefix End Get Set(ByVal value As String) _table_prefix = value End Set End Property Class DatabaseListConverter Inherits DbStringConverter Public Overrides Function GetStandardValuesSupported(ByVal context As ITypeDescriptorContext) As Boolean Return True End Function Public Overrides Function GetStandardValuesExclusive(ByVal context As ITypeDescriptorContext) As Boolean Return True End Function Public Overrides Function GetStandardValues(ByVal context As ITypeDescriptorContext) As StandardValuesCollection Return GetShowDatabases() End Function End Class End Class 

PS Naturally, I understand that you can cycle through the list, compare values ​​and find an object.

  • if only one: First , if several Where - Grundy
  • it does not tell me anything ... - Dmitriy Nail
  • one
    These are Linq methods that return one or more objects that satisfy the condition, and for the links provided there are examples of using these methods - Grundy

1 answer 1

 Dim db As ExDatabase = databaseList.First(Function(item) item.DataBase = "databaseTest")