Snippet. Vala. Convert String to Integer

To convert a String to integer (int) in Vala use the int.parse() method.

int number = int.parse("123");

Warning. The to_int() method used in previous versions of Vala is deprecated and will result in warning:

string string_number = "123";
int number = string_number.to_int();

Result:

warning: string.to_int is deprecated. Use int.parse

Updated on: 21 Dec 2024