.net 哈希表和字典的基本用法
2024-08-24 09:41:04
哈希表
传送门: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();
}
}
}
最新文章
- Android Studio —— 创建Menu菜单项
- iptables不生效解决办法
- QT通过IP地址定位地址(用get方法取数据)
- [译]Java垃圾回收是如何工作的
- /usr,/usr/local/ 还是 /opt ?
- Java RESTful 框架的性能比较
- MMU二级页表
- VS2015离线安装NuGet Package
- Sharepoint 2010 工作流状态值
- LeetCode题解之Balanced Binary Tree
- mvc:message-converters简单介绍
- CentOS下Yum的$releasever和$basearch的取值
- 配置Codis-Service主机
- Jackson JSON Processor
- shell 脚本调试
- java基础二 java的跨平台特性
- java之接口开发-初级篇-http和https
- endwith与startwith字符串方法匹配重写
- Struct2小组开发简单命名规范
- Linux下C程序进程地址空间布局[转]
热门文章
- .net 实用功能
- 版本控制[0] ->; git ->; 使用 git 进行版本控制
- [Python Cookbook] Pandas: 3 Ways to define a DataFrame
- 「kuangbin带你飞」专题十七 AC自动机
- Ext分区文件恢复工具extundelete
- the-swift-programming-language 学习笔记
- 【bzoj1485:】【 [HNOI2009]有趣的数列】模任意数的卡特兰数
- SQL 增删改查 复习
- About Markdown -- 进入Markdown园子
- 【NOIP模拟赛】【乱搞AC】【贪心】【模拟】匹配