当前位置:网站首页>Usage of C set
Usage of C set
2022-07-01 01:05:00 【Geek style】
stay C# in , Sets are divided into generic sets and non generic sets , The interfaces and classes of non generic collections are in System.Collections In the namespace , The interfaces and classes of generic collections are System.Collections.Generic In the namespace .
ArrayList For dynamic list , Is a non generic linear list , You can add the data you need to manage to this list , Then a series of operations .
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class s1: MonoBehaviour {
void Start () {
ArrayList list = new ArrayList();// Initialize the dynamic list object
list.Add("Jobs"); // Add string data to the list
list.Add("Linus");
list.Add("Jensen");
print(list[1]); //Linus
print(list.IndexOf("Jobs") //0
print(list.Count); // Number of elements in the print list :3
List.RemoveAt(1);// take Linus remove
print(list.Count);// Number of elements in the print list :2
print(list.Contains("Linus");// Determine if there is an element “Linus”, return false
list.Clear();// Clear the list , The list is empty after clearing
void Update () {
}
}
ArrayList Is a non generic interface , Each of its elements is defined as object type , This is why we can ArrayList Add any type of data to the object of , Because in C# in ,Everything is object. When we add... To the list int Type of data , Due to int Type conversion to object type , At this time, the packing operation occurs . In the code above , What we're adding is string Data of type , and string The type itself is a reference type , Therefore, although there is no aseng packing operation here , However, due to the type of installation and replacement , So there will still be problems of efficiency and security . therefore , It is not recommended that you use non generic collections , You should try to use generic collections to store data .
边栏推荐
- Some views on libco
- 2022-2028 global weight loss ginger tea industry research and trend analysis report
- Wechat official account development (1) introduction to wechat official account
- Teach you how to use Hal library to get started -- become a lighting master
- Left join displays the specified value when the left join matching data is null
- 连表查询 select 生成
- 2022-2028 global plant peptone industry research and trend analysis report
- 2022就要过去一半了,挣钱好难
- Unit test concept and purpose
- 2022-2028 global electric yacht industry research and trend analysis report
猜你喜欢

C#生成putty格式的ppk文件(支持passphrase)

Get to know the drawing component of flutter - custompaint

CentOS install MySQL

Confirm() method of window

NE555 waveform generator handle tutorial NE555 internal structure (I)

剑指 Offer 19. 正则表达式匹配

初识 Flutter 的绘图组件 — CustomPaint

2022-2028 global mobile scanning radiology room industry survey and trend analysis report

NE555波形发生器手把手教程之NE555内部结构(一)

Date类的实现
随机推荐
P4 learning - p4runtime
Pytorch auto derivation
深度学习的历史
SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding
Integer to hexadecimal string PTA
PHP online confusion encryption tutorial sharing + basically no solution
CMU15445 (Fall 2019) 之 Project#1 - Buffer Pool 详解
20220216 misc buuctf backdoor killing (d shield scanning) - clues in the packet (Base64 to image)
Oracle-数据完整性
实验八 T-sql,存储过程
什么是产品思维
P4学习——p4runtime
20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking
问题解决:如何管理线程私有(thread_local)的指针变量
写给 5000 粉丝的一封信!
History of deep learning
Introduction to ES6 promise, new features of ES7 and es8 async and await
The principle of journal node
Shift operators
20220215-ctf-misc-buuctf-einstein-binwalk analyze picture-dd command separate zip file -- look for password in picture attribute