.net 哈希表和字典的基本用法
哈希表
传送门:https://www.cnblogs.com/xpvincent/archive/2013/01/15/2860841.html
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApp
{
class Program
{
static string hashToPostString(Hashtable ht) {
string str = "";
foreach (DictionaryEntry de in ht) {
str += de.Key + "=" + de.Value + "&";
}
return str.Substring(, str.Length - );
} static void Main(string[] args)
{
Hashtable ht = new Hashtable();
ht.Add("username", "");
ht.Add("password", "202063sb");
ht.Add("geetest_challenge", "3c2f03027eb7cac324a7cf67f148441d");
ht.Add("geetest_validate", "21fa24dfd285b955776fd349c5bc5834");
ht.Add("geetest_seccode", "21fa24dfd285b955776fd349c5bc5834|jordan"); string str = hashToPostString(ht);
Console.Write(str);
Console.ReadLine();
}
}
}
字典
传送门:http://blog.csdn.net/voodooer/article/details/19233105
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApp
{
class Program
{
static string DictionaryToPostString(Dictionary<string, string> ht) {
string str = "";
foreach (KeyValuePair<string, string> de in ht) {
str += de.Key + "=" + de.Value + "&";
}
return str.Substring(, str.Length - );
} static void Main(string[] args)
{ //定义字典
Dictionary<string, string> d = new Dictionary<string, string>();
d.Add("gt", "geetest.gt");
d.Add("challenge", "geetest.challenge");
d.Add("model", "");
d.Add("referer", "http://www.228.com.cn/auth/login");
d.Add("return", "json");
d.Add("user", "dragon8jiyan");
d.Add("pass", ""); string str = DictionaryToPostString(d);
Console.Write(str);
Console.ReadLine();
}
}
}
.net 哈希表和字典的基本用法的更多相关文章
- 数据结构图解(递归,二分,AVL,红黑树,伸展树,哈希表,字典树,B树,B+树)
递归反转 二分查找 AVL树 AVL简单的理解,如图所示,底部节点为1,不断往上到根节点,数字不断累加. 观察每个节点数字,随意选个节点A,会发现A节点的左子树节点或右子树节点末尾,数到A节点距离之差 ...
- 哈希表和字典List和Ilist和array和arraylist的应用
string x = string.Empty; string y = string.Empty; Hashtable ht = new Hashtable(); ...
- 使用python实现哈希表、字典、集合
哈希表 哈希表(Hash Table, 又称为散列表),是一种线性表的存储结构.哈希表由一个直接寻址表和一个哈希函数组成.哈希函数h(k)将元素关键字k作为自变量,返回元素的存储下标. 简单哈希函数: ...
- C#集合类:动态数组、队列、栈、哈希表、字典(转)
1.动态数组:ArrayList 主要方法:Add.AddRange.RemoveAt.Remove 2.队列:Queue 主要方法:Enqueue入队列.Dequeue出队列.Peek返回Queue ...
- C#集合类:动态数组、队列、栈、哈希表、字典
1.动态数组:ArrayList 主要方法:Add.AddRange.RemoveAt.Remove 2.队列:Queue 主要方法:Enqueue入队列.Dequeue出队列.Peek返回Queue ...
- repeater绑定数组、哈希表、字典 ArrayList/HashTable,Dictionary为datasource
原文发布时间为:2009-11-19 -- 来源于本人的百度文章 [由搬家工具导入] repeater绑定数组、哈希表、字典datasource为ArrayList/HashTable,Diction ...
- Redis原理再学习04:数据结构-哈希表hash表(dict字典)
哈希函数简介 哈希函数(hash function),又叫散列函数,哈希算法.散列函数把数据"压缩"成摘要,有的也叫"指纹",它使数据量变小且数据格式大小也固定 ...
- C# 通俗说 哈希表
1.何谓哈希 哈希,也程散列.哈希表是一种与数组,链表等不同的数据结构,与他们需要不断的 遍历比较查找的办法,哈希表设计了一个映射关系发f(key)=adress,根据key来计算adress, 这样 ...
- C#-集合及特殊集合——★★哈希表集合★★
集合的基本信息: System.Collections命名空间包含接口和类,这些接口和类定义各种对象(如列表.队列.位组数.哈希表和字典)的集合. System.Collections.Generic ...
随机推荐
- J.U.C并发框架源码阅读(七)CyclicBarrier
基于版本jdk1.7.0_80 java.util.concurrent.CyclicBarrier 代码如下 /* * ORACLE PROPRIETARY/CONFIDENTIAL. Use is ...
- [BZOJ2142]礼物(扩展Lucas)
2142: 礼物 Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 2286 Solved: 1009[Submit][Status][Discuss] ...
- bzoj 3462: DZY Loves Math II
3462: DZY Loves Math II Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 211 Solved: 103[Submit][Sta ...
- redis --- lua 脚本实现原子操作
如题, 楼主的想法很简单, lua 脚本本身支持原子性, 所以把命令写进一个脚本就行, 当然后续还会优化才能放到生产上,例如缓存脚本 ,redis 本身会缓存执行过的脚本 ,这样速度更快, 再优化, ...
- u-boot-2015.01在tq2440上的初步移植
作者: 彭东林 邮箱: pengdonglin137@163.com QQ: 405728433 开发板: tq2440 工具: Win7 + VMware + Debian6 ...
- mysql-cluster集群(亲测)
重要说明:mysql-cluste与非集群时用的mysql-server与mysql-client没有任何关系,mysql-cluste安装包中已自带了集群用的server与client,启动mysq ...
- mysql 的常用查询
Ø 基本常用查询 --select select * from student; --all 查询所有 select all sex from student; --distinct 过滤重复 ...
- 阿里云域名绑定IP
前提条件:拥有一个阿里云域名,拥有一台自己的服务器,并且知道ip,我的是nginx 1.登陆阿里云https://www.aliyun.com/ 2.选择域名与网站,会看到自己拥有的域名,比如我的是m ...
- log4j教程 4、配置
上一章介绍log4j的核心组件.本章介绍如何使用配置文件来配置这些核心组件.配置log4j涉及分配级别,定义追加程序,并在配置文件中指定布局的对象. log4j.properties文件是一个键 - ...
- log4j教程 2、安装
Log4j的API包使用Apache软件许可证,由开源倡议认证一个完全成熟的开源许可证下发布. 最新log4j的版本,包括完整的源代码,类文件和文档可以在这里找到 http://logging.apa ...