本文介绍了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转换为字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!