Share via


Struct.value Method

Definition

Overloads

value(String)

Gets or sets the value for a specified item in a struct.

value(String, Object)

value(String)

Gets or sets the value for a specified item in a struct.

public:
 virtual System::Object ^ value(System::String ^ _fieldName);
public virtual object value (string _fieldName);
abstract member value : string -> obj
override this.value : string -> obj
Public Overridable Function value (_fieldName As String) As Object

Parameters

_fieldName
String

The value to assign to the item; optional.

Returns

The value of the specified item.

Remarks

An exception is raised if there is no item with the specified name in the struct. The name of an item in a struct may be retrieved by using the Struct.fieldName method. You can add a new item to a struct and assign a value to it at the same time by using the Struct.add method. To assign a new value to an item based on its position in the struct, use the Struct.valueIndex method.

The following example creates a struct with two items in it and then uses the value method to assign values to those two items.

{ 
    Struct s = new Struct ("str name; int age"); 
    // Set the values 
    s.value("name", "Jane Dow"); 
    s.value("age", 34); 
    // Print the values 
    print s.value("name"); 
    print s.value("age"); 
    pause; 
}

Applies to

value(String, Object)

public:
 virtual System::Object ^ value(System::String ^ _fieldName, System::Object ^ _value);
public virtual object value (string _fieldName, object _value);
abstract member value : string * obj -> obj
override this.value : string * obj -> obj
Public Overridable Function value (_fieldName As String, _value As Object) As Object

Parameters

_fieldName
String
_value
Object

The value to assign to the item; optional.

Returns

Applies to