.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 ...
随机推荐
- AC日记——The Meeting Place Cannot Be Changed codeforces 780b
780B - The Meeting Place Cannot Be Changed 思路: 二分答案: 代码: #include <cstdio> #include <cstrin ...
- c# await 到底等待的是什么?
static void Main(string[] args) { Print(); Console.WriteLine("5 :::" + Thread.CurrentThrea ...
- 【bzoj1226】【[SDOI2009]学校食堂Dining】状压dp
(上不了p站我要死了,侵权度娘背锅) Description 小F 的学校在城市的一个偏僻角落,所有学生都只好在学校吃饭.学校有一个食堂,虽然简陋,但食堂大厨总能做出让同学们满意的菜肴.当然,不同的人 ...
- 导出/导入Eclipse的workspace配置(备份Eclipse配置)
设置好workspace配置后可以将配置保存为 *.epf 文件. 进入 File -> Export : 选择 General -> Preferences ,下一步: 选择 Expor ...
- SQL SERVER Update from 使用陷阱
原文:SQL SERVER Update from 使用陷阱 update A set from A left join B on 此方法常用来使用根据一个表更新另一个表的数据,来进行数据同步更新.若 ...
- IE8下 input标签内padding失效
在做网页兼容时 发现在ie8下的input内用padding失效 为了达到居中文字的效果 使用line-height可以解决问题
- 常用函数 __MySQL必知必会
----------------------使用数据处理函数 ---------------------- 常见的文本处理函数 Left() 返回串左边的字符Length() 返回串的长度Locate ...
- crossapp里的位置设置
crossapp里有Frame.Center,这两种都是可以用来确定一个view的位置和大小. 不同点:Frame定位是以View的左上角为参照点,Center是以View的中心点为参照点 注意cro ...
- Python 面向对象三(转载)
来源:Mr.Seven www.cnblogs.com/wupeiqi/p/4766801.html 四.类的特殊成员 上文介绍了Python的类成员以及成员修饰符,从而了解到类中有字段.方法和属性三 ...
- 机器学习第4课:多变量线性回归(Linear Regression with Multiple Variables)
4.1 多维特征 目前为止,我们探讨了单变量/特征的回归模型,现在我们对房价模型增加更多的特征, 例如房间数楼层等,构成一个含有多个变量的模型,模型中的特征为(x1,x2,...,xn).