Description
The ToULong
method is a static extension method provided by the SandboxSystemExtensions
class. It is used to convert a string representation of a number into a 64-bit unsigned integer (UInt64
). If the conversion fails, it returns a default value specified by the caller.
Usage
To use the ToULong
method, call it on a string instance that you want to convert to a UInt64
. Provide a default value that will be returned if the conversion is not successful.
This method is particularly useful when you want to safely parse a string to a UInt64
without throwing exceptions for invalid input.
Example
string numberString = "123456789";
ulong defaultValue = 0;
ulong result = numberString.ToULong(defaultValue);
// result will be 123456789 if the conversion is successful.
// If the string cannot be converted, result will be 0 (the default value).