当前位置:网站首页>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 .
边栏推荐
- 一文掌握数仓中auto analyze的使用
- Commvault 和 Oracle 合作,在 Oracle 云上提供 Metallic数据管理即服务
- 2022年中国移动阅读市场年度综合分析
- CVPR 2022 | TransFusion:用Transformer进行3D目标检测的激光雷达-相机融合
- Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
- 数据库锁表?别慌,本文教你如何解决
- After installing vscode, the program runs (an include error is detected, please update the includepath, which has been solved for this translation unit (waveform curve is disabled) and (the source fil
- Implementation mode and technical principle of MT4 cross platform merchandising system (API merchandising, EA merchandising, nj4x Merchandising)
- 使用Scrcpy投屏
- PostgreSQL 9.1 soaring Road
猜你喜欢

Master the use of auto analyze in data warehouse
高效!用虚拟用户搭建FTP工作环境

高质量软件架构的唯一核心指标

2022KDD预讲 | 11位一作学者带你提前解锁优秀论文

三星量产3纳米产品引台媒关注:能否短期提高投入产出率是与台积电竞争关键

CommVault cooperates with Oracle to provide metallic data management as a service on Oracle cloud

It is six orders of magnitude faster than the quantum chemical method. An adiabatic artificial neural network method based on adiabatic state can accelerate the simulation of dual nitrogen benzene der

洞见科技解决方案总监薛婧:联邦学习助力数据要素安全流通

CA: efficient coordinate attention mechanism for mobile terminals | CVPR 2021

阿里云有奖体验:用PolarDB-X搭建一个高可用系统
随机推荐
再说rsync+inotify实现数据的实时备份
从0到1建设智能灰度数据体系:以vivo游戏中心为例
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
Is the outdoor LED screen waterproof?
runc hang 导致 Kubernetes 节点 NotReady
6 分钟看完 BGP 协议。
Apache server access log access Log settings
Golang sets the small details of goproxy proxy proxy, which is applicable to go module download timeout and Alibaba cloud image go module download timeout
Agile development / agile testing experience
CTF competition problem solution STM32 reverse introduction
WPF double slider control and forced capture of mouse event focus
PostgreSQL 9.1 飞升之路
面试官:Redis 过期删除策略和内存淘汰策略有什么区别?
CANN算子:利用迭代器高效实现Tensor数据切割分块处理
Solution: how to delete the information of Jack in two tables with delete in one statement in Oracle
Comprehensive evaluation of modular note taking software: craft, notation, flowus
CA:用于移动端的高效坐标注意力机制 | CVPR 2021
Don't turn down, three sentences to clarify the origin of cross domain resource request errors
Rsyslog configuration and use tutorial
FS4056 800mA充电ic 国产快充电源ic