asp.net-mvc在操作后获取字典或如何将FormCollection转换为字典 [英] asp.net-mvc get a dictionary in post action or how to transform FormCollection into a dictionary

查看:154
本文介绍了asp.net-mvc在操作后获取字典或如何将FormCollection转换为字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何将FormCollection转换为IDictionary或如何在后期操作中获取IDictionary吗?

anybody knows how to transform the FormCollection into a IDictionary or how to get a IDictionary in the post action ?

推荐答案

这与Omnu的代码等效,但对我来说似乎更优雅:

This is just an equivalent of Omnu's code, but it seems more elegant to me:

Dictionary<string, string> form = formCollection.AllKeys.ToDictionary(k => k, v => formCollection[v]);

这篇关于asp.net-mvc在操作后获取字典或如何将FormCollection转换为字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆