When to use a Cast or Convert

Cast when it’s really a type of int, Convert when it’s not an int but you want it to become one.

For example int i = (int)o; when you know o is an int

int i = Convert.ToInt32("123") because “123” is not an int, it’s a string representation of an int.

Leave a Comment