到底是什么 [英] What exactly is Casting

查看:106
本文介绍了到底是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一定有人问过这个问题,但究竟是什么?我需要一个非常粗糙的解释,之后可以使用任何/所有与C#相关的单词.
谢谢你. :)

Someone must have asked this before but what exactly is casting. i need a very crude explanation after which any/all the C# related words can be used.
Thank you. :)

推荐答案

强制类型转换将转换操作符从一种类型显式调用为另一种类型.如果未定义此类转换运算符,则转换将失败.您可以编写自定义转换运算符以在用户定义的类型之间进行转换

http://g4ac.co.za/C-Sharp_Casting [ http://g4ac.co.za/5k5du [
A cast explicitly invokes the conversion operator from one type to another. The cast will fail if no such conversion operator is defined. You can write custom conversion operators to convert between user-defined types

http://g4ac.co.za/C-Sharp_Casting[^]

http://g4ac.co.za/5k5du[^]


"If a conversion cannot be made without a risk of losing information, the compiler requires that you perform an explicit conversion, which is called a cast. A cast is a way of explicitly informing the compiler that you intend to make the conversion and that you are aware that data loss might occur. To perform a cast, specify the type that you are casting to in parentheses in front of the value or variable to be converted. The following program casts a double to an int. The program will not compile without the cast."



除了
[ ^ ]



Can''t get any more crude than this[^].


广播对编译器说: 我很想知道数据类型不匹配,无论如何我" m是Master,而您只是一个工具,所以请关闭并编译以下fuc#* n语句" .
cast is saying to the compiler: "I''m freaking aware the data types don''t match, anyway I''m the Master and you just a tool, so shut up and compile this fuc#*n statement".


这篇关于到底是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆