当前位置:网站首页>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 .
边栏推荐
- 高质量软件架构的唯一核心指标
- 比量子化学方法快六个数量级,一种基于绝热状态的绝热人工神经网络方法,可加速对偶氮苯衍生物及此类分子的模拟
- Runc hang causes the kubernetes node notready
- Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
- Samsung's mass production of 3nm products has attracted the attention of Taiwan media: whether it can improve the input-output rate in the short term is the key to compete with TSMC
- Is the outdoor LED screen waterproof?
- Xue Jing, director of insight technology solutions: Federal learning helps secure the flow of data elements
- 阿里云有奖体验:用PolarDB-X搭建一个高可用系统
- 再说rsync+inotify实现数据的实时备份
- [FAQ] summary of common causes and solutions of Huawei account service error 907135701
猜你喜欢

Commvault 和 Oracle 合作,在 Oracle 云上提供 Metallic数据管理即服务

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

"Pre training weekly" issue 52: shielding visual pre training and goal-oriented dialogue

ASP.NET Core入门一

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

CANN算子:利用迭代器高效实现Tensor数据切割分块处理
高效!用虚拟用户搭建FTP工作环境

Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?

AI painting minimalist tutorial
Efficient! Build FTP working environment with virtual users
随机推荐
A taste of node JS (V), detailed explanation of express module
Two dimensional code coding theory
Runc hang causes the kubernetes node notready
Three schemes to improve the efficiency of MySQL deep paging query
Deploy halo blog with pagoda
XML入门二
微服务入门
XML入门一
AI 绘画极简教程
Rsyslog configuration and use tutorial
面向个性化需求的在线云数据库混合调优系统 | SIGMOD 2022入选论文解读
求解:在oracle中如何用一条语句用delete删除两个表中jack的信息
Valentine's Day confession code
6 分钟看完 BGP 协议。
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
[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
聊聊支付流程的设计与实现逻辑
HAProxy高可用解决方案
8个扩展子包!RecBole推出2.0!
实时云交互如何助力教育行业发展