当前位置:网站首页>Why does the C# compiler allow an explicit cast between IEnumerable< T> and TAlmostAnything?
Why does the C# compiler allow an explicit cast between IEnumerable< T> and TAlmostAnything?
2022-07-05 22:21:00 【French red wine sweet】
problem :
The following code gives you a compiler error, as you'd expect: The following code provides you with compiler errors , As you would expect :
List<Banana> aBunchOfBananas = new List<Banana>();Banana justOneBanana = (Banana)aBunchOfBananas;However, when using IEnumerable<Banana> , you merely get a runtime error. however , Use IEnumerable<Banana> , Only runtime errors will occur .
IEnumerable<Banana> aBunchOfBananas = new List<Banana>();Banana justOneBanana = (Banana)aBunchOfBananas;Why does the C# compiler allow this? Why? C# The compiler allows this ?
Solution :
Reference resources : https://stackoom.com/en/question/capE边栏推荐
- Leetcode simple question check whether all characters appear the same number of times
- Solutions for unexplained downtime of MySQL services
- GWT module may need to be (RE) compiled reduce - GWT module may need to be (RE) compiled reduce
- 344. Reverse String. Sol
- A substring with a length of three and different characters in the leetcode simple question
- Some tutorials install the database on ubantu so as not to occupy computer memory?
- Comment développer un plug - in d'applet
- 等到产业互联网时代真正发展成熟,我们将会看待一系列的新产业巨头的出现
- Sparse array [matrix]
- Three "factions" in the metauniverse
猜你喜欢

Alternating merging strings of leetcode simple questions

Decorator learning 01

opencv 判断点在多边形内外

Two stage locking protocol for concurrency control

Three "factions" in the metauniverse

The real situation of programmers
![[error record] groovy function parameter dynamic type error (guess: groovy.lang.missingmethodexception: no signature of method)](/img/3e/34b45cd14f0302bb381efd244bc68f.jpg)
[error record] groovy function parameter dynamic type error (guess: groovy.lang.missingmethodexception: no signature of method)

Business learning of mall order module

Meituan dynamic thread pool practice ideas, open source

Server optimization of performance tuning methodology
随机推荐
极狐公司官方澄清声明
2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
Metaverse Ape获Negentropy Capital种子轮融资350万美元
Shelved in TortoiseSVN- Shelve in TortoiseSVN?
IIC bus realizes client device
The difference between MVVM and MVC
344. Reverse String. Sol
如何開發引入小程序插件
Implementation technology of recovery
Livelocks and deadlocks of concurrency control
Analyse des risques liés aux liaisons de microservices
MySQL服务莫名宕机的解决方案
Sparse array [matrix]
What about data leakage? " Watson k'7 moves to eliminate security threats
Matlab draws a cute fat doll
Decorator learning 01
Official clarification statement of Jihu company
Kubernetes Administrator certification (CKA) exam notes (IV)
Pl/sql basic syntax
1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]