First, you’ve turned around a bit since the “wider” one is usually used for less derived types. For instance. Control wider than Label , because the definition covers everything that comes from Control , which includes Label , as well as other things.
Regarding the urgent issue. There are times when you can argue the pros and cons, for example. a method that returns what is actually List<T> , returning it as List<T> or IList<T> or ICollection<T> or IEnumerable<T> . There are some good principles that we can apply to this solution, but there remains an advantage in that, and in the other direction, as far as possible, it can remain useful and as narrow as possible.
However, this is not applicable here. There is no way that Control.FindControl() could return a Label unless it was defined only to return labels. This is not what it is for, it is for returning any type of control, and therefore the result can be just as easily a repeater or grid.
You yourself say SaveViewState , "cast to can be a string type." The answer is that it’s possible. Of course, it can be a string, but it can be object[] or List<string> or Dictionary<string, string> .
If you were the programmer who wrote SaveViewState , how would you define it? You must cover all these possibilities and much more, so you will need to define it as a returning object .
source share