开发者

Explanation Casting and Conversion - What is the difference in simple words

开发者 https://www.devze.com 2023-02-03 15:28 出处:网络
What is the differences between Casting and Conversion operation in C#. Please explanation in simple way for beginners.

What is the differences between Casting and Conversion operation in C#. Please explanation in simple way for beginners.

Thanks for开发者_StackOverflow your help!

Resources: http://msdn.microsoft.com/en-us/library/ms173105%28v=VS.100%29.aspx


Casting is an attempt to change the type of a variable without changing the representation (so casting an int to a long doesn't change the underlying structure).

Converting is changing the type and the internal representation (converting a string to an integer - very different internal representations).


You have different type of conversion, casting is one of them.


To cast is to temporarily treat one type as another type where as to convert is to permanently change it.

0

精彩评论

暂无评论...
验证码 换一张
取 消