I have a huge code base and I recently made a change where I changed the type of a parameter from String
to a custom class. On the next compile I got all the areas where the impact was, but areas where the input type was of type Object
failed. for e.g.
String str = "32"
int i = Convert.ToInt32(str)
Now I have changed String
to a new custom type lets say MyCustomClass
I would now want following code to fail on next compile
MyCustomClass str = new MyCustomClass("32")
int i = Convert.ToInt32(str)
but it won't as Convert.ToInt32
also accepts type Object
. Is there some way I can make a change in MyCustomClass
that it's not considered Object
anymore.
Please note: Convert.ToInt32
is only used for sample I have many more such functions, so please focus your suggestion/answer to question asked.