Cast vs 'as' operator revisited

后端 未结 5 989
长情又很酷
长情又很酷 2020-12-24 02:33

I know there are several posts already concerning the difference between casts and the as operator. They all mostly restate the same facts:

  • The
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 03:15

    It is a matter of type safety.
    Any T cannot by convert to a Bar, but any Tcan be "seen" as a Bar since the behavior is well defined even if there is no conversion from T to Bar.

提交回复
热议问题