ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Editing.Attributes Namespace / Inspector Class / TryGetValue Method
A string value to search for desired attribute field name. This search is case insensitive.
If an attribute with the provided name is found, its value is returned via the out value parameter. If not found, it is set to null.
Example

In This Topic
    TryGetValue Method
    In This Topic
    Gets the current value of the attribute specified by fieldName.
    Syntax
    public bool TryGetValue( 
       string fieldName,
       out object value
    )
    Public Function TryGetValue( _
       ByVal fieldName As String, _
       ByRef value As Object _
    ) As Boolean

    Parameters

    fieldName
    A string value to search for desired attribute field name. This search is case insensitive.
    value
    If an attribute with the provided name is found, its value is returned via the out value parameter. If not found, it is set to null.

    Return Value

    True if the inspector contains an attribute with the specified fieldName. False otherwise.
    Example
    Adds a custom validation rule to the "Mineral" field of the specified feature layer.
    await QueuedTask.Run(() =>
    {
      var insp = new Inspector();
      insp.LoadSchema(featureLayer);
    
      bool success = insp.TrySetValue("mineral", "Salt");
      object result = null;
      success = insp.TryGetValue("mineral", out result);
      if (result != null && success)
      {
        MessageBox.Show($"Successfully stored and retrieved the value of field 'Mineral': {result.ToString()}");
      }
    
      var attrib = insp.Where(a => a.FieldName == "Mineral").First();
      attrib.AddValidate(() =>
      {
        if (attrib.CurrentValue.ToString() == "Salt")
        {
          return [];
        }
        else
        {
          return [ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError.Create("Error", Severity.Low)];
        }
      });
    });
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.8 or higher.
    See Also