static bool TryParse( string str, System.IFormatProvider info, Vector2Int& result )

robot_2Generated
code_blocksInput

Description

The Vector2Int.TryParse method attempts to convert a string representation of a 2D integer vector into a Vector2Int object. It returns a boolean value indicating whether the parsing was successful. This method is useful for safely converting strings to Vector2Int without throwing exceptions if the format is incorrect.

Usage

To use the TryParse method, provide the string to be parsed, an IFormatProvider for culture-specific formatting, and an output parameter to store the result if parsing is successful. The method returns true if the parsing is successful, otherwise false.

Example

string input = "10,20";
IFormatProvider formatProvider = CultureInfo.InvariantCulture;
Vector2Int result;

bool success = Vector2Int.TryParse(input, formatProvider, out result);

if (success)
{
    // Parsing was successful, use the result
    // result.x == 10, result.y == 20
}
else
{
    // Handle the parsing failure
}