In the first example; unboxing (that you show) is different from the slide or conversion; perhaps unfortunately C # uses the same syntax for all 3.
You must correctly remove value types (e.g. int / double). Or use Convert.ToInt32(y)one that has logic for this inline.
( unbox, downcast). (, ), .
- object. .