OPC Studio User's Guide and Reference
TryGetValue Method (_EnumerationMemberCollection)



OpcLabs.BaseLib Assembly > OpcLabs.BaseLib.DataTypeModel.ComTypes Namespace > _EnumerationMemberCollection Interface : TryGetValue Method
The key of the item to search in the collection.

The value of this parameter can be null (Nothing in Visual Basic).

When this method returns true, the item from the collection that matches the provided key; when this method returns false, the default value for the type of the collection.

The value of this parameter can be null (Nothing in Visual Basic).

Tries to get an item from the collection using the specified key.
Syntax
'Declaration
 
Function TryGetValue( _
   ByVal key As String, _
   ByRef item As Object _
) As Boolean
'Usage
 
Dim instance As _EnumerationMemberCollection
Dim key As String
Dim item As Object
Dim value As Boolean
 
value = instance.TryGetValue(key, item)
bool TryGetValue( 
   string key,
   out object item
)
bool TryGetValue( 
   String^ key,
   [Out] Object^ item
) 

Parameters

key
The key of the item to search in the collection.

The value of this parameter can be null (Nothing in Visual Basic).

item
When this method returns true, the item from the collection that matches the provided key; when this method returns false, the default value for the type of the collection.

The value of this parameter can be null (Nothing in Visual Basic).

Return Value

true if an item for the specified key was found in the collection; otherwise, false.
Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

Remarks

This member or type is for use from COM. It is not meant to be used from .NET or Python. Refer to the corresponding .NET member or type instead, if you are developing in .NET or Python.

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also