当前位置:网站首页>C array supplement
C array supplement
2022-07-04 13:42:00 【Hua Weiyun】
c# A few simple additions to the array
An array is a reference type , Whether its element is a value type or a reference type .
c# Various interfaces implemented by array objects in :
// Defines the ability of shallow copy , So arrays can be shallow copied System.ICloneable// ICollection Interface descendants , Use interface programming to reduce coupling , This interface only defines some methods , With indexer , Query element location , insert data , Remove the index location data , It can be simply used as a container for storing data , Can not be like List That has a lot of data processing methods .System.Collections.IList// The parent base class of the collection , Defines the number of return elements , Some of the most basic methods of collection types, such as copying , At the same time, it provides synchronous access ICollection Methods of object elements , Arrays have these capabilities System.Collections.ICollection// Define the ability of iterative traversal , Arrays can be used foreach loop System.Collections.IEnumerable// .net4 New interface , Defines the ability to sort , Data can be sorted, so System.Collections.IStructuralComparable// .net4 New interface , Define comparative capabilities , Array can compare whether the array has the same content. If the number of elements is different, it directly returns unequal , Having several elements at the same time will perform several comparisons System.Collections.IStructuralEquatable// Indexers are also provided , There are several ways to delete and insert query data , But it's generic data /* special , By default, all arrays inherit from Array abstract class , This class implements the above interface , But when looking at the source code, you can't see that the array implements the following interfaces , These interfaces are really CLR Dynamically implement the following interfaces for one-dimensional arrays */System.Collections.Generic.IList <T>// The ability to provide generics , It also has the basic function of adding, deleting, modifying and checking System.Collections.Generic.ICollection <T>// A type can use linq iteration , The interface must be changed , So arrays can use linq Inquire about .System.Collections.Generic.IEnumerable <T>// read-only list, Access the read-only through the index list The elements of System.Collections.Generic.IReadOnlyList <T>// Read only set , Access the elements of the read-only collection through the index System.Collections.Generic.IReadOnlyCollection <T>
Code view :
foreach (var type in (new int[0,0]).GetType().GetInterfaces()) Console.WriteLine(type);
By executing this code , When the array created is a one-dimensional array , The array object will implement the generic interface , You can have linq The ability to query , But when it's not a one-dimensional array , At this time, the data does not have linq The ability of , At this time, the array object does not implement the generic interface .
These movements are made by CLR ( Common language runtime ) Executive , The internal principle is not clear , But in general linq Queries are operations on collections , Arrays belong to collections , But because there are multidimensional arrays , Arrays cannot be implemented directly IEnumerable Generic interface get linq The ability to query , Instead, managed code is run by CLR Responsible for handling , Give interface capabilities to one-dimensional arrays , Non one dimensional arrays cannot have interface capabilities .
Of course, all of the above are for reference types , Value types do not have such operations that dynamically empower interfaces .
边栏推荐
- 《预训练周刊》第52期:屏蔽视觉预训练、目标导向对话
- 面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
- CANN算子:利用迭代器高效实现Tensor数据切割分块处理
- PostgreSQL 9.1 soaring Road
- MySQL three-level distribution agent relationship storage
- 干货整理!ERP在制造业的发展趋势如何,看这一篇就够了
- 聊聊支付流程的设计与实现逻辑
- 7 月数据库排行榜:MongoDB 和 Oracle 分数下降最多
- DGraph: 大规模动态图数据集
- Meituan Ali's Application Practice on multimodal recall
猜你喜欢
Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
Meituan Ali's Application Practice on multimodal recall
MDK在头文件中使用预编译器时,#ifdef 无效的问题
阿里云有奖体验:用PolarDB-X搭建一个高可用系统
Is the outdoor LED screen waterproof?
PostgreSQL 9.1 soaring Road
Three schemes to improve the efficiency of MySQL deep paging query
JVM系列——栈与堆、方法区day1-2
Zhongang Mining: in order to ensure sufficient supply of fluorite, it is imperative to open source and save flow
N++ is not reliable
随机推荐
Comprehensive evaluation of modular note taking software: craft, notation, flowus
CA: efficient coordinate attention mechanism for mobile terminals | CVPR 2021
从0到1建设智能灰度数据体系:以vivo游戏中心为例
Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?
WPF double slider control and forced capture of mouse event focus
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
[AI system frontier dynamics, issue 40] Hinton: my deep learning career and research mind method; Google refutes rumors and gives up tensorflow; The apotheosis framework is officially open source
mysql三级分销代理关系存储
求解:在oracle中如何用一条语句用delete删除两个表中jack的信息
Is the outdoor LED screen waterproof?
一个数据人对领域模型理解与深入
PostgreSQL 9.1 飞升之路
三星量产3纳米产品引台媒关注:能否短期提高投入产出率是与台积电竞争关键
【AI系统前沿动态第40期】Hinton:我的深度学习生涯与研究心法;Google辟谣放弃TensorFlow;封神框架正式开源
CVPR 2022 | transfusion: Lidar camera fusion for 3D target detection with transformer
Definition of cognition
.NET 使用 redis
Rsyslog配置及使用教程
游戏启动后提示安装HMS Core,点击取消,未再次提示安装HMS Core(初始化失败返回907135003)
SQL language