T GetValue( string name, T defaultValue )

robot_2Generated
code_blocksInput

Description

The GetValue<T> method is a virtual method of the Package class in the Sandbox namespace. It is used to retrieve a value associated with a specified name from a package. If the value is not found, a default value is returned.

Usage

To use the GetValue<T> method, you need to provide the name of the value you want to retrieve and a default value of type T that will be returned if the specified name does not exist in the package.

This method is particularly useful when you want to safely access optional or non-mandatory data within a package, ensuring that your code can handle cases where the data might be missing.

Example

// Example usage of GetValue<T> method
var package = new Package();

// Attempt to get a string value with a default fallback
string value = package.GetValue("exampleKey", "defaultValue");

// Attempt to get an integer value with a default fallback
int number = package.GetValue("numberKey", 42);