How to Convert System.Object into int ?

I want to convert Object into int.

Object foo = 100;
int bar = Int32.Parse(foo);

'>>InvalidCastException: Cannot cast from source type to destination type.

How should I do?

Thank you.

Object foo = 100;

this is not possible, Object is Unity.Object, try to use object instead which is the mother class of all:

object foo = 100;
int bar = (int)foo;