知识点总结: c#,使用自定义类型来作为Dictionary的Key

CMSIS-FreeRTOS源码审计:内核架构、移植层与工程实践解析 实时操作系统(RTOS)是嵌入式系统实现多任务并发与实时响应的核心基础,而FreeRTOS凭借其开源、轻量及高可移植性成为Cortex-M平台的主流选择。其任务调度器、队列通信、内存管理及中断处理等机制,决定了系统在复杂场景下的稳定性与实时性。CMSIS-FreeRTOS作为Arm官方整合版本,进一步统一了内核、移植层与CMSIS-RTOS2 API,支持AC5、AC6及GCC多编译器环境,广泛应用于IoT终端、工业控制及消费电子领域。本文从源码静态审计视角出发,系统拆解任务调度、内存分配、软定时器及上下文 阅读详情

首先来看一个变量的定义:

/// <summary>
        /// key依次是StationId,channelId,deviceId,paraType,dataId,dataTypeId,logicalDeviceIndex,paraHandle,sourceId,value是paraName。读取PC_TB_35_07表后,再找到相应的SourceId后,保存到这里.保存的是定时记录
        /// </summary>
        private
            Dictionary
                <uint,
                    Dictionary
                        <uint, Dictionary<uint, Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, string>>>>>
                            >>>> m_PC_TB_35_07DatalogDic =
                                new Dictionary
                <uint,
                    Dictionary
                        <uint, Dictionary<uint, Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, string>>>>>
                            >>>>();

看不懂吧?看起来很困难吧。其实就是因为key有多个字段,但是写代码的人并没有想到可以使用使用自定义类型来作为key,所以就使用Dictionary套Dictionary的方式,这种方式会导致用的时候也很痛苦,例如,要一层一层的判断,这样就导致了每次使用,要做n次字典的查找,我数了一下,HasDatalog的一次调用,会导致17次的字典查找,实际上只需要一两次就够了。

public bool HasDatalog(uint stationId, uint channelId, uint deviceId)
        {
            if (!GetDatalogForChannel(stationId, channelId))
                return false;
            if (!m_PC_TB_35_07DatalogDic.ContainsKey(stationId))
                return false;
            if (!m_PC_TB_35_07DatalogDic[stationId].ContainsKey(channelId))
                return false;
            if (!m_PC_TB_35_07DatalogDic[stationId][channelId].ContainsKey(deviceId))
                return false;
            if (!m_PC_TB_35_07DatalogDic[stationId][channelId][deviceId].ContainsKey(1))
                return false;
            if (m_PC_TB_35_07DatalogDic[stationId][channelId][deviceId][1].Count == 0)
                return false;
            return true;            
        }

所以考虑使用自定义结构来作为Dictionary的Key,示例代码如下,其实主要就是要让自定义类型实现IEqualityComparer接口,而这里面最关键的就是要实现GetHashCode,好在这个结构的字段不多,所以就参考一下《C#本质论(第三版)》p267的实现,大致的代码如下。


using System.Collections.Generic;

namespace TestDictionary
{
     struct DatalogValue
    {
        public int paraHandle;
        public int paraName;
    }

    struct DatalogKey : IEqualityComparer<DatalogKey>
    {
        public DatalogKey(uint dataId, uint dataTypeId, uint logicalDeviceIndex)
        {
            this.dataId = dataId;
            this.dataTypeId = dataTypeId;
            this.logicalDeviceIndex = logicalDeviceIndex;
        }

        public uint dataId;
        public uint dataTypeId;
        public uint logicalDeviceIndex;

        public bool Equals(DatalogKey x, DatalogKey y)
        {
            return x.dataId == y.dataId &&
                   x.dataTypeId == y.dataTypeId && 
                   x.logicalDeviceIndex == y.logicalDeviceIndex;
        }

        public int GetHashCode(DatalogKey obj)
        {
            int hashCode = dataId.GetHashCode();
            if (hashCode != dataTypeId.GetHashCode())            
                hashCode ^= dataTypeId.GetHashCode();                            
            if (hashCode != logicalDeviceIndex.GetHashCode())
                hashCode ^= dataTypeId.GetHashCode();
            return hashCode;
        }
    }
}

测试:


using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace TestDictionary
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Dictionary<DatalogKey, int> testDataLog = new Dictionary<DatalogKey, int>();
            testDataLog.Add(new DatalogKey(1, 1, 1), 1);
            testDataLog.Add(new DatalogKey(1, 2, 1), 2);
            testDataLog.Add(new DatalogKey(1, 3, 1), 3);
            testDataLog.Add(new DatalogKey(2, 1, 1), 4);
            testDataLog.Add(new DatalogKey(2, 2, 1), 4);
            MessageBox.Show(testDataLog[new DatalogKey(2, 1, 1)].ToString());

            if(!testDataLog.ContainsKey(new DatalogKey(2,1,2)))
                MessageBox.Show("no");

        }
    }
}


根据value来定位key在C#的Dictionary中如何实现? 在C#中Dictionary位于System.Collections.Generic,其定义为: 阅读详情

相关推荐

C# Dictionary中的key修改

在C#中,Dictionary<TKey, TValue> 的键(key)是不可变的。一旦你将一个键值对添加到字典中,你就不能直接修改这个键。如果你需要更改键,你需要先删除旧的键值对,然后插入一个新的键值对。在这个示例中,我们首先创建了一个包含三个键值对的字典。检查旧键是否存在:使用 ContainsKey 方法来检查字典中是否包含要更改的键。添加新的键值对:使用 Add 方法将新的键和旧的值添加到字典中。获取旧键对应的值:如果键存在,则获取该键对应的值。// 添加新的键值对。// 打印更新后的字典。

精通搬砖,资深技术砖家,在软件开发,人工智能,设备开发等领域都有研究。商业合作&交流学习可私信联系。 1417

【术】c#字典Dictionary自定义类作为key键

最近事情有点多,总是想直接贴代码,先放上去再说吧。

Kingous-惊蛰 4856

Dictionary详解(C#)

Dictionary定义 在C#中,Dictionary能提供快速的基于键值的元素查找。我们先来看一下源代码: public class Dictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, ID

weixin_46433786的博客 6846

Unity中 使用c# 自定义的值类型作为dictionary的key需注意

public struct DictStruct : IEquatable<DictStruct> { public int x; public int y; public DictStruct(int x) { this.x = x; y = 0; } public bool Equals(DictStruct other) { return x == other.x; } public override int GetHashCode() { retur.

Kt_KID的专栏 1342

C# Dictionary分别按Key,Value值升降序排序

Dictionary<char, int> dic = new Dictionary<char, int>(); dic.Add('a', 1); dic.Add('b', 2); dic.Add('c', 1); dic.Add('d', 3); dic.Add('e', 8); 结果: ①dicsort1 :按key值升序 Dictionary<char, int> dicsort1 = dic.OrderBy(o => o.Key).ToDict.

The world forgets me! 3733

C#自定义可序列化的Dictionary类型

C#自定义可序列化的Dictionary类型

GetHashCode()初探

Effective C# Item 10: Understand the Pitfalls of GetHashCode() 读后感 下面的内容中有很多一部分是笔者自己的想法,所以有些说法可能会有失偏颇,还望指正。 Wanger说GetHashCode()是他在Effective C#所有的50个建议中唯一一项关于不推荐函数的建议。GetHashCode()这个方法只会用于一个地方:给基于...

weixin_30746117的博客 261

C#实现自定义Dictionary类实例

主要介绍了C#实现自定义Dictionary类,较为详细的分析了Dictionary类的功能、定义及用法,具有一定参考借鉴价值,需要的朋友可以参考下

C# 使用自定义类+字典+JSON填充数据,脱离真实数据库,实现简单的增删改查和本地存储与读取数据

本文章适合的情况:①适合数据表少的项目。②适合将数据存储在本地的项目。③适合不想依赖复杂的数据库环境,同时想拥有存储和增删改查数据的功能的项目。④不优雅,不聪明,但是很简单粗暴,可以快速实现.

阿修罗汉果茶的博客 2885

工业自动化中气动夹爪选型、调试与维护全流程实战解析

在工业自动化领域,气动执行元件是实现精准抓取与搬运的基础。其工作原理是通过压缩空气驱动气缸,转化为直线或旋转运动,从而控制夹爪的开合。这类技术因其结构简单、响应快速、成本低廉及维护方便,在自动化产线中具有极高的技术价值,是实现高效、可靠物料搬运的核心单元。其典型应用场景涵盖电子装配、汽车制造、食品包装等行业的上下料、分拣与定位工序。本文以工业自动化中常见的二指平行气动夹爪(常被工程师代号化为“Gripper-A”)为例,深入剖析其从硬件选型、气动系统集成到程序逻辑联锁的完整工程实践。内容聚焦于夹持力计算中惯

weixin_42629671的博客 369

有关SPSS中Fisher精确检验无法进行的解决方法(由于无法打开临时文件,因此无法进行计算)

最近在帮一个四年生完成她的毕业论文,在用SPSS进行R×C表检验的时候,发现Fisher精确检验的结果无法显示,提示为“由于无法打开临时文件,因此无法进行计算”,大概像下图一样。 (这图是从网上找的) 然...

chuyang37的博客 3万+

C# 之 Dictionary 详解

▪ 说明 必须包含名空间 System.Collection.Generic Dictionary里面的每一个元素都是一个键值对(由二个元素组成:键和值) 键必须是唯一的,而值不需要唯一的 键和值都可以是任何类型(比如:string, int, 自定义类型等等) 可以简单将 Dictionary 理解为 键值对 数据的集合 ▪ 常规使用方法 // 定义 Dictionary<string, string> dictExecutes = new Dictionary<string,

外来物种 2万+

java调用第三方api接口获取数据

弊端,但是并不是每个接口都适用于这套模板,之前写的接口不适用,都是在这个模板里做了定制处理(if 特殊表 -》处理),需要考虑兼容之前的代码,这种兼容代码,有风险会改掉之前的逻辑个人喜欢,有一个接口,写一段代码灵活自由些。2.还有一部分是对post请求的返回数据,做处理,因为json返回的格式如果双方没有约定好,里面数据是多层json嵌套,需要做处理。江同事交接的就是这个代码模板,可以看下源码调试一下,之前交接的视频,也可以看下,主要还是看代码理解快些,将 写好的代码达成jar包,上传到linux上去,

随风不随水的博客 2037

C#中:字典Dictionary<Key, Value>的用法

在C#中,Dictionary的主要用途是提供快速的基于键值的元素查找。Dictionary的结构一般是这样的:Dictionary ,它包含在System.Collections.Generic命名空间中。在使用Dictionary前,你必须对它的键类型和值类型进行声明。

qq_42384612的博客 5721

地图可视化类型大全

地图可视化类型大全: 散点地图 网格地图 聚合地图 气泡地图 热力图 Choropleth地图/分级设色地图/分级区域地图/着色地图/分级统计地图(百度百科这样翻译)/等值域地图/分段设色地图 Cartogram地图/变形地图/示意地图 规则形状地图 /RecMap/Demers Cartogram/瓷砖网格地图/DorlingMap 流型图(Flow Map)\流线图\流向图\轨迹地图 复合地图

codeuniverse的博客 3536

K8S搭建(centos)完整版

每个人都有惰性,但不断学习是好好生活的根本,共勉!

感谢阅读 4150

C#中Dictionary(字典)的用法

在C#中,Dictionary提供快速的基于兼职的元素查找。他的结构是这样的:Dictionary<[key], [value]> ,当你有很多元素的时候可以使用它。它包含在System.Collections.Generic名空间中。在使用前,你必须声明它的键类型和值类型。 方法/步骤 要使用Dictionary集合,需要导入C#泛型命名空间 System...

Peter的博客 9860

RK3588 Android12 添加HDMI和喇叭声音通道切换选项

rk3588 android12系统默认接hdmi out时,声音会切换到hdmi out输出,主板声卡喇叭输出会没有声音输出。现在添加一个选项设置hdmi out时,声音可以保持主板声卡喇叭输出。

Android系统开发笔记 4171

C# 之Dictionary字典 的使用详解

字典的键不仅可以是基本类型,还可以是自定义类型,但必须确保自定义类型的 Equals和 GetHashCode方法是正确实现的,因为字典使用这些方法来判断键是否相等。set;set;// 使用 Person 作为字典的键C# 中的是一种非常高效的键值对存储结构,提供了常见的查找、插入、删除等操作,并且能够处理键值对数据。确保键是唯一的。注意字典的顺序问题,字典不保证键值对顺序。使用方法可以避免因键不存在而抛出异常。使用自定义类型作为字典的键时,需要重写Equals和方法。

weixin_45590420的博客 1656

AD9361功能介绍和使用

AD9361使用分数分频锁相环(PLL)来产生发射机和接收机本地振荡器(LO)频率和BB PLL。BB PLL 可用于数据转换、数字滤波器和 |/O 端口。PLL的参考时钟可以由外部振荡器或外部晶体(XO)和数字可编程片内可变电容提供,电容微调产生参考时钟频率,XO和微调电容的组合统称为DCXO。有多个天线输入的分集系统。接收链数据首先经过低噪声放大器(LNA),然后是同相(1)和正交(Q)放大器,混频器和频带整形滤波器,可将接收到的信号下变频为基带以进行数字化。时分双工(TDD)和频分双工(FDD)。。。

wangjie36的博客 1万+

基于STM32设计的万能红外遥控器(学习型)

当前介绍了一种基于STM32微控制器设计的红外遥控器,支持接收解码功能和发送功能,可以将接收的码原样发送出去。 红外遥控器作为智能设备控制方式之一,在一定程度上满足了人们对于快速方便控制的需求。 当前设计的红外遥控器支持学习模式和发送模式。通过矩阵键盘上的数字键选择发送对应的控制码。 一共支持学习10个控制码,对应矩阵键盘上的数字。0~9。

6560

c# 字典Dictionary

作者:曾志伟 链接:https://zhuanlan.zhihu.com/p/96633352 来源:知乎 C# 用了两三年,然后突然有一天被问到C#Dictionary的基本实现,这让我反思到我一直处于拿来主义,能用就好,根本没有去考虑和学习一些底层架构,想想令人头皮发麻。下面开始学习一些我平时用得理所当然的东西,今天先学习一下字典的源码。 一、Dictionary源码学习 Dictionary实现我们主要对照源码来解析,目前对照源码的版本是.Net Framwork 4.8。 源码地址:dicti

qq_40097668的博客 2万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C# Dictionary通过value获取对应的key值

1:最直白的循环遍历方法,可以分为遍历key--value键值对以及所有的key两种表现形式 2:用Linq的方式去查询(当然了这里要添加对应的命名空间 using System.Linq) 如下为

linjcai的博客 5765

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

C# Dictionary

Dictionary有Key跟Value,一个Key只能对应一种Value,但一种Value可以对应很多种Key 像是学生座号和成绩,每个人只会对应到一个成绩,但也许有人同时考到相同的分数 下面是官方的范例 using System; using System.Collections.Generic; public class Example { public static void M...

GTWLin的博客 4394

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

C# Dictionary 字典的使用

C# Dictionary 字典的使用 说明 必须包含名空间System.Collection.Generic Dictionary里面的每一个元素都是一个键值对(由二个元素组成:键和值) 键必须是唯一的,而值不需要唯一的 键和值都可以是任何类型(比如:string, int, 自定义类型,等等) 通过一个键读取一个值的时间是接近O(1) 键值对之间的偏序可以不定义 使用 //定义 Dictionary<string, string> openWith = new Dictionary&

weixin_51803498的博客 2235

C#中Dictionary的用法

在C#中,Dictionary提供快速的基于兼职的元素查找。他的结构是这样的:Dictionary ,当你有很多元素的时候可以使用它。它包含在System.Collections.Generic名空间中。在使用前,你必须声明它的键类型和值类型。要使用Dictionary集合,需要导入C#泛型命名空间System.Collections.Generic(程序集:mscorlib)Dictionary的描述1、从一组键(Key)到一组值(Value)的映射,每一个添加项都是由一个......

zhanchulan的博客 1万+
上一篇: 类库: vc下如何按照当前系统的日期、时间格式显示时间
下一篇: 新项目中用 C# or Java
strinkbug
博客等级 码龄24年 0粉丝 9原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值