.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 ...
随机推荐
- poj 1873(枚举所有的状态+凸包)
The Fortified Forest Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6115 Accepted: 1 ...
- (14)oracle数据字典
http://czmmiao.iteye.com/blog/1258462 数据字典解释 1.user_tables 查询用户所拥有的所有表 select table_name from user_t ...
- Python的程序结构[4] -> 函数/Function[2] -> 匿名函数
匿名函数 / Anonymous Function 匿名函数是一种不需要绑定函数名的函数 (i.e. functions that are not bound to a name).匿名函数通过 la ...
- [Python Cookbook] Pandas Groupby
Groupby Count # Party’s Frequency of donations nyc.groupby(’Party’)[’contb receipt amt’].count() The ...
- 洛谷——P1029 最大公约数和最小公倍数问题
P1029 最大公约数和最小公倍数问题 题目描述 输入二个正整数x0,y0(2<=x0<100000,2<=y0<=1000000),求出满足下列条件的P,Q的个数 条件: 1 ...
- luogu P1164 小A点菜
题目背景 uim神犇拿到了uoi的ra(镭牌)后,立刻拉着基友小A到了一家……餐馆,很低端的那种. uim指着墙上的价目表(太低级了没有菜单),说:“随便点”. 题目描述 不过uim由于买了一些辅(e ...
- mac下eclipse导入windows项目文件乱码
右键property->resource没有GBK,手工输入"GBK"项目正常. 一开始用windows被坑了,如果再用windows平台,第一时间将encoding改成UT ...
- Bluetooth篇 开发实例之十一 官网的Bluetooth Chat sample的bug
当没有匹配的设备和没有找到可用设备的时候. // If there are paired devices, add each one to the ArrayAdapter if (pairedDev ...
- ArcMAP中如何将16位保存的卫星底图,转变为8位表示
首先说明,这种转换将会去除影像的投影像素的定义,并在转换后变为黑色的部分.16位的存储,一方面也是定义透明非数据像素点表示的方便.但是这种定义直接加大了影像的大小,不便于与CAD等软件进行交换数据.
- zookeeper 学习笔记3
ZooKeeper 允许客户端向服务端注册一个 Watcher 监听, ZooKeeper 允许客户端向服务端注册一个 Watcher 监听, ZooKeeper 允许客户端向服务端注册一个 Watc ...