What is the difference between explicit and implicit type casts?

后端 未结 10 923
太阳男子
太阳男子 2020-12-04 18:15

Can you please explain the difference between explicit and implicit type casts?

10条回答
  •  生来不讨喜
    2020-12-04 18:16

    Explicit from MSDN -

    If a conversion operation can cause exceptions or lose information, you should mark it explicit. This prevents the compiler from silently invoking the conversion operation with possibly unforeseen consequences.

    Implicit from MSDN -

    if the conversion is guaranteed not to cause a loss of data

提交回复
热议问题