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.
精彩评论