当前位置:网站首页>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 .
边栏推荐
- 2022-2028 global carbon fiber room scraper system industry research and trend analysis report
- 2022-2028 global capsule shell industry research and trend analysis report
- Implementation of date class
- left join左连接匹配数据为NULL时显示指定值
- The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
- [2023 MediaTek approved the test questions in advance] ~ questions and reference answers
- 深度学习的历史
- Detailed analysis of operators i++ and ++i in JS, i++ and ++i
- Error 2059 when Navicat connects to MySQL
- Gavin's insight on the transformer live broadcast course - rasa project's actual banking financial BOT Intelligent Business Dialogue robot system startup, language understanding, dialogue decision-mak
猜你喜欢

Implementation of date class

Line number of Jenkins pipeline script execution exception

初识 Flutter 的绘图组件 — CustomPaint

Left join displays the specified value when the left join matching data is null

【日常记录】——对BigDecimal除法运算时遇到的Bug

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

2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report

C # Generate PPK files in Putty format (passthrough support)

Chapter 53 overall understanding of procedures from the perspective of business logic implementation

2022-2028 global retro glass industry research and trend analysis report
随机推荐
20220215 CTF misc buuctf Xiaoming's safe binwalk analysis DD command separate rar file archpr brute force password cracking
Teach you how to use Hal library to get started -- become a lighting master
C#生成putty格式的ppk文件(支持passphrase)
The longest selling mobile phone in China has been selling well since its launch, crushing iphone12
20220216 misc buuctf backdoor killing (d shield scanning) - clues in the packet (Base64 to image)
From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
CSDN常用复杂公式模板记录
HDU 2488 A Knight's Journey(DFS)
连表查询 select 生成
Unit test concept and purpose
2022-2028 global electric yacht industry research and trend analysis report
CentOS installation starts redis
Metauniverse and virtual reality (II)
1009 product of polynomials (25 points) [PTA class A]
Error 2059 when Navicat connects to MySQL
Oracle-数据完整性
2022-2028 global single travel industry research and trend analysis report
20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking
A single element in an ordered array
双链表:初始化 插入 删除 遍历